/*! sapar - v0.1.0 - 2015-01-11 */(function($, undefined) {
    // prevent duplicate loading
    // this is only a problem because we proxy existing functions
    // and we don't want to double proxy them
    // 如果有值在进行赋值，否则赋值为空，确保不是undefined
    $.ued = $.ued || {};
	
	if (!window.JSON) {
		window.JSON = {};
	}
	(function () {
		"use strict";
		function f(n) {
			// Format integers to have at least two digits.
			return n < 10 ? '0' + n : n;
		}

		if (typeof Date.prototype.toJSON !== 'function') {

			Date.prototype.toJSON = function (key) {

				return isFinite(this.valueOf()) ?
					this.getUTCFullYear()     + '-' +
					f(this.getUTCMonth() + 1) + '-' +
					f(this.getUTCDate())      + 'T' +
					f(this.getUTCHours())     + ':' +
					f(this.getUTCMinutes())   + ':' +
					f(this.getUTCSeconds())   + 'Z' : null;
			};

			String.prototype.toJSON      =
				Number.prototype.toJSON  =
				Boolean.prototype.toJSON = function (key) {
					return this.valueOf();
				};
		}

		var cx = /[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,
			escapable = /[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,
			gap,
			indent,
			meta = {    // table of character substitutions
				'\b': '\\b',
				'\t': '\\t',
				'\n': '\\n',
				'\f': '\\f',
				'\r': '\\r',
				'"' : '\\"',
				'\\': '\\\\'
			},
			rep;


		function quote(string) {

	// If the string contains no control characters, no quote characters, and no
	// backslash characters, then we can safely slap some quotes around it.
	// Otherwise we must also replace the offending characters with safe escape
	// sequences.

			escapable.lastIndex = 0;
			return escapable.test(string) ? '"' + string.replace(escapable, function (a) {
				var c = meta[a];
				return typeof c === 'string' ? c :
					'\\u' + ('0000' + a.charCodeAt(0).toString(16)).slice(-4);
			}) + '"' : '"' + string + '"';
		}


		function str(key, holder) {

	// Produce a string from holder[key].

			var i,          // The loop counter.
				k,          // The member key.
				v,          // The member value.
				length,
				mind = gap,
				partial,
				value = holder[key];

	// If the value has a toJSON method, call it to obtain a replacement value.

			if (value && typeof value === 'object' &&
					typeof value.toJSON === 'function') {
				value = value.toJSON(key);
			}

	// If we were called with a replacer function, then call the replacer to
	// obtain a replacement value.

			if (typeof rep === 'function') {
				value = rep.call(holder, key, value);
			}

	// What happens next depends on the value's type.

			switch (typeof value) {
			case 'string':
				return quote(value);

			case 'number':

	// JSON numbers must be finite. Encode non-finite numbers as null.

				return isFinite(value) ? String(value) : 'null';

			case 'boolean':
			case 'null':

	// If the value is a boolean or null, convert it to a string. Note:
	// typeof null does not produce 'null'. The case is included here in
	// the remote chance that this gets fixed someday.

				return String(value);

	// If the type is 'object', we might be dealing with an object or an array or
	// null.

			case 'object':

	// Due to a specification blunder in ECMAScript, typeof null is 'object',
	// so watch out for that case.

				if (!value) {
					return 'null';
				}

	// Make an array to hold the partial results of stringifying this object value.

				gap += indent;
				partial = [];

	// Is the value an array?

				if (Object.prototype.toString.apply(value) === '[object Array]') {

	// The value is an array. Stringify every element. Use null as a placeholder
	// for non-JSON values.

					length = value.length;
					for (i = 0; i < length; i += 1) {
						partial[i] = str(i, value) || 'null';
					}

	// Join all of the elements together, separated with commas, and wrap them in
	// brackets.

					v = partial.length === 0 ? '[]' : gap ?
						'[\n' + gap + partial.join(',\n' + gap) + '\n' + mind + ']' :
						'[' + partial.join(',') + ']';
					gap = mind;
					return v;
				}

	// If the replacer is an array, use it to select the members to be stringified.

				if (rep && typeof rep === 'object') {
					length = rep.length;
					for (i = 0; i < length; i += 1) {
						if (typeof rep[i] === 'string') {
							k = rep[i];
							v = str(k, value);
							if (v) {
								partial.push(quote(k) + (gap ? ': ' : ':') + v);
							}
						}
					}
				} else {

	// Otherwise, iterate through all of the keys in the object.

					for (k in value) {
						if (Object.prototype.hasOwnProperty.call(value, k)) {
							v = str(k, value);
							if (v) {
								partial.push(quote(k) + (gap ? ': ' : ':') + v);
							}
						}
					}
				}

	// Join all of the member texts together, separated with commas,
	// and wrap them in braces.

				v = partial.length === 0 ? '{}' : gap ?
					'{\n' + gap + partial.join(',\n' + gap) + '\n' + mind + '}' :
					'{' + partial.join(',') + '}';
				gap = mind;
				return v;
			}
		}

	// If the JSON object does not yet have a stringify method, give it one.

		if (typeof window.JSON.stringify !== 'function') {
			window.JSON.stringify = function (value, replacer, space) {

	// The stringify method takes a value and an optional replacer, and an optional
	// space parameter, and returns a JSON text. The replacer can be a function
	// that can replace values, or an array of strings that will select the keys.
	// A default replacer method can be provided. Use of the space parameter can
	// produce text that is more easily readable.

				var i;
				gap = '';
				indent = '';

	// If the space parameter is a number, make an indent string containing that
	// many spaces.

				if (typeof space === 'number') {
					for (i = 0; i < space; i += 1) {
						indent += ' ';
					}

	// If the space parameter is a string, it will be used as the indent string.

				} else if (typeof space === 'string') {
					indent = space;
				}

	// If there is a replacer, it must be a function or an array.
	// Otherwise, throw an error.

				rep = replacer;
				if (replacer && typeof replacer !== 'function' &&
						(typeof replacer !== 'object' ||
						typeof replacer.length !== 'number')) {
					throw new Error('JSON.stringify');
				}

	// Make a fake root object containing our value under the key of ''.
	// Return the result of stringifying the value.

				return str('', {'': value});
			};
		}


	// If the JSON object does not yet have a parse method, give it one.

		if (typeof window.JSON.parse !== 'function') {
			window.JSON.parse = function (text, reviver) {

	// The parse method takes a text and an optional reviver function, and returns
	// a JavaScript value if the text is a valid JSON text.

				var j;

				function walk(holder, key) {

	// The walk method is used to recursively walk the resulting structure so
	// that modifications can be made.

					var k, v, value = holder[key];
					if (value && typeof value === 'object') {
						for (k in value) {
							if (Object.prototype.hasOwnProperty.call(value, k)) {
								v = walk(value, k);
								if (v !== undefined) {
									value[k] = v;
								} else {
									delete value[k];
								}
							}
						}
					}
					return reviver.call(holder, key, value);
				}


	// Parsing happens in four stages. In the first stage, we replace certain
	// Unicode characters with escape sequences. JavaScript handles many characters
	// incorrectly, either silently deleting them, or treating them as line endings.

				text = String(text);
				cx.lastIndex = 0;
				if (cx.test(text)) {
					text = text.replace(cx, function (a) {
						return '\\u' +
							('0000' + a.charCodeAt(0).toString(16)).slice(-4);
					});
				}

	// In the second stage, we run the text against regular expressions that look
	// for non-JSON patterns. We are especially concerned with '()' and 'new'
	// because they can cause invocation, and '=' because it can cause mutation.
	// But just to be safe, we want to reject all unexpected forms.

	// We split the second stage into 4 regexp operations in order to work around
	// crippling inefficiencies in IE's and Safari's regexp engines. First we
	// replace the JSON backslash pairs with '@' (a non-JSON character). Second, we
	// replace all simple value tokens with ']' characters. Third, we delete all
	// open brackets that follow a colon or comma or that begin the text. Finally,
	// we look to see that the remaining characters are only whitespace or ']' or
	// ',' or ':' or '{' or '}'. If that is so, then the text is safe for eval.

				if (/^[\],:{}\s]*$/
						.test(text.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g, '@')
							.replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g, ']')
							.replace(/(?:^|:|,)(?:\s*\[)+/g, ''))) {

	// In the third stage we use the eval function to compile the text into a
	// JavaScript structure. The '{' operator is subject to a syntactic ambiguity
	// in JavaScript: it can begin a block or an object literal. We wrap the text
	// in parens to eliminate the ambiguity.

					j = eval('(' + text + ')');

	// In the optional fourth stage, we recursively walk the new structure, passing
	// each name/value pair to a reviver function for possible transformation.

					return typeof reviver === 'function' ?
						walk({'': j}, '') : j;
				}

	// If the text is not JSON parseable, then a SyntaxError is thrown.

				throw new SyntaxError('JSON.parse');
			};
		}
	}());
	
    if ($.ued.version) {
        return;
    }

    $.extend($.ued, {
        version : "2.0",
        keyCode : {
            TAB : 9,
            ENTER : 13,
            ESCAPE : 27,
            SPACE : 32,
            LEFT : 37,
            UP : 38,
            RIGHT : 39,
            DOWN : 40
        },
        lang : {
            // 获取属性的国际化字符串，如果组件的options中已经设置这个值就直接使用，否则从$.ued.lang[comp]中获取
            _get : function(options, comp, attr) {
                return options[attr] ? options[attr] : $.ued.lang[comp][attr];
            }
        }
    });
    // plugins
    $.fn.extend({
        propAttr : $.fn.prop || $.fn.attr,
        _oldFocus : $.fn.focus, //为避免与jQuery ui冲突导致死循环，这里不要取名为'_focus'
        //设置元素焦点（delay：延迟时间）
        focus : function(delay, fn) {
            return typeof delay === "number" ? this.each(function() {
                var elem = this;
                setTimeout(function() {
                    $(elem).focus();
                    if (fn) {
                        fn.call(elem);
                    }
                }, delay);
            }) : this._oldFocus.apply(this, arguments);
        },
        //获取设置滚动属性的 父元素
        scrollParent : function() {
            var scrollParent;
            if (($.browser.msie && (/(static|relative)/).test(this.css('position'))) || (/absolute/).test(this.css('position'))) {
                scrollParent = this.parents().filter(function() {
                    return (/(relative|absolute|fixed)/).test($.curCSS(this, 'position', 1)) && (/(auto|scroll)/).test($.curCSS(this, 'overflow', 1) + $.curCSS(this, 'overflow-y', 1) + $.curCSS(this, 'overflow-x', 1));
                }).eq(0);
            } else {
                scrollParent = this.parents().filter(function() {
                    return (/(auto|scroll)/).test($.curCSS(this, 'overflow', 1) + $.curCSS(this, 'overflow-y', 1) + $.curCSS(this, 'overflow-x', 1));
                }).eq(0);
            }
            return (/fixed/).test(this.css('position')) || !scrollParent.length ? $(document) : scrollParent;
        },
        //设置或获取元素的垂直坐标
        zIndex : function(zIndex) {
            if (zIndex !== undefined) {
                return this.css("zIndex", zIndex);
            }
            if (this.length) {
                var elem = $(this[0]), position, value;
                while (elem.length && elem[0] !== document) {
                    // Ignore z-index if position is set to a value where z-index is ignored by the browser
                    // This makes behavior of this function consistent across browsers
                    // WebKit always returns auto if the element is positioned
                    position = elem.css("position");
                    if (position === "absolute" || position === "relative" || position === "fixed") {
                        // IE returns 0 when zIndex is not specified
                        // other browsers return a string
                        // we ignore the case of nested elements with an explicit value of 0
                        // <div style="z-index: -10;"><div style="z-index: 0;"></div></div>
                        value = parseInt(elem.css("zIndex"), 10);
                        if (!isNaN(value) && value !== 0) {
                            return value;
                        }
                    }
                    elem = elem.parent();
                }
            }
            return 0;
        },
        //设置元素不支持被选择
        disableSelection : function() {
            return this.bind(($.support.selectstart ? "selectstart" : "mousedown" ) + ".om-disableSelection", function(event) {
                event.preventDefault();
            });
        },
        //设置元素支持被选择
        enableSelection : function() {
            return this.unbind(".om-disableSelection");
        }
    });
    $.fn.extend({
		/**
		  * add by ynshen
		  * 扩展show，支持参数visibility（本质是通过样式控制visibility）
		  */
        _oldShow : $.fn.show,
        show : function(type) {
            if (type != "visibility") {
                return this._oldShow.apply(this, arguments);
            } else {
                return this.css("visibility", "visible");
            }
        },
		/**
		  * add by ynshen
		  * 扩展hide，支持参数visibility（本质是通过样式控制visibility）
		  */
        _oldHide : $.fn.hide,
        hide : function(type) {
            if (type != "visibility") {
                return this._oldHide.apply(this, arguments);
            } else {
                return this.css("visibility", "hidden");
            }
        }
    });
	$.extend({
		/**
		  * add by xzjiang
		  * 判断字符串数（中文占俩位）
		  * @param {Object} message
		  */
		getStrLength : function(message) {
			return message.replace(/([\u4E00-\u9FA5\uf900-\ufa2d])/g, 'aa').length;
		}
	});
	
	/**
	  * add by ynshen
	  * 判断浏览器是否支持console对象
	  * 如果不支持（当为IE并且未打开调试窗口时，初始化console对象，并将console.log方法指向window.alert方法）
	  */
	  window.property = {};
	if(!window.console){
		window.console = {};
		window.console.log = function(data){
			window.alert(data)
		}
		//add by rbai(增加time和timeEnd性能测试函数) 
		if(!window.console.time){
			window.console.time = function(name){
				window.property[name] = new Date().getTime();
			}
			window.console.timeEnd = function(name){
				var tempTime = new Date().getTime()
				window.alert(name+'==='+(tempTime - window.property[name])+'ms');
			}
		}
	}
	
	//增加debug模式
	if(!window.DebugModel){
		window.DebugModel = {},window.deBugObj = {};
		window.DebugModel.start = function(name){
			window.deBugObj[name] = +new Date();
		}
		window.DebugModel.end = function(name){
			var tempTime = +new Date();
			var tempConsole = name+'完成花费了'+(tempTime - window.deBugObj[name])+'ms';
			DebugModel._printLog(tempConsole);
		}
		window.DebugModel._printLog = function(log){
			var $debugConsole = $('.ued-debugConsole',$('body'));
			if(!$debugConsole.size()){//如果存在debug控制台元素
				$('body').append('<div class="ued-debugConsole" style="position:absolute;top:10px;left:10px;background:#F9F9F9;border:1px solid #CCC;padding:5px 10px 20px 10px;z-index:99999;color:#666;box-shadow:1px 1px 1px white inset;text-shadow:1px 1px 1px #FFF;">'+
				'<h6 style="border-bottom:1px dashed #999;margin-bottom:5px;">UED DEBUG 控制台</h6>'+
				'<div class="ued-debugContent uew-scroll-webkit" style="max-height:300px;overflow:auto;"></div>'+
				'<a href="javascript:;" class="ued-debugClose" style="position:absolute;bottom:2px;right:5px;">关闭</a>'+
				'</di>');
				$debugContent = $('.ued-debugContent',$('body'));
				DebugModel._initCloseOrShow();
			}
			$('.ued-debugConsole',$('body')).show();
			$debugContent.append('<p>'+ log +'</p>');
		}
		
		window.DebugModel._initCloseOrShow = function($debugConsole){
			$('.ued-debugClose',$('body')).click(function(e) {
				$debugContent.empty();
                $('.ued-debugConsole',$('body')).hide();
            });
			
		}
	}
	/**
	  * add by ynshen
	  * 对象深度复制方法
	  */
	window.DeepCopy = function(obj){
		var copyObj = new Object();
		for (prop in obj)
		{
			if(obj[prop] != null && obj[prop].constructor == Object){
				copyObj[prop] = window.DeepCopy(obj[prop]);
			}
			else{
				copyObj[prop] = obj[prop]
			}
		}
		return copyObj;
	}

    ////框架原本的这个扩展造成jquery pivot grid使用jquery3.3.1版本时报错:Cannot read property 'length' of undefined--wxj20180828
	///**
	//  * add by ynshen
	//  * 扩展Array对象，增加删除数组中指定元素方法
	//  */

	//Array.prototype.remove = function (element) {
	//    //debugger;
	//	var indexArr = [];
	//	var outArr = [];
	//	//找到出现该元素的index并存入数组indexArr
	//	for(var i = 0;i < this.length;i++){
	//		if(this[i] == element){
	//			indexArr.push(i);
	//		}
	//	}
	//	if(indexArr.length > 0){
	//		for(var j = 0;j < indexArr.length;j++){
	//			if(j == 0){//切分头部
	//				outArr = outArr.concat(this.slice(0,indexArr[j]));
	//			}else{//切分中段
	//				outArr = outArr.concat(this.slice(indexArr[j - 1] + 1,indexArr[j]));
	//			}
	//		}
	//		//切分尾端
	//		outArr = outArr.concat(this.slice(indexArr[j - 1] + 1,this.length));
	//		return outArr;
	//	}else{
	//		throw new Error(element + "can't be found in " + this);
	//	}
	//}
	
    //框架原本的这个扩展造成jquery DataTables使用jquery3.3.1版本时报错:s.match为null引用--wxj20180823
    //// 扩展innerWidth、innerHeight、outerWidth和outerHeight方法，如果不传参则获取值，如果传参则设置计算后的宽高。
    //$.each(["Width", "Height"], function(i, name) {
    //    var side = name === "Width" ? ["Left", "Right"] : ["Top", "Bottom"], type = name.toLowerCase(), orig = {
    //        innerWidth : $.fn.innerWidth,
    //        innerHeight : $.fn.innerHeight,
    //        outerWidth : $.fn.outerWidth,
    //        outerHeight : $.fn.outerHeight
    //    };

    //    function reduce(elem, size, border, margin) {
    //        $.each(side, function() {
    //            size -= parseFloat($.curCSS(elem, "padding" + this, true)) || 0;
    //            if (border) {
    //                size -= parseFloat($.curCSS(elem, "border" + this + "Width", true)) || 0;
    //            }
    //            if (margin) {
    //                size -= parseFloat($.curCSS(elem, "margin" + this, true)) || 0;
    //            }
    //        });
    //        return size;
    //    }

    //    $.fn["inner" + name] = function(size) {
    //        if (size === undefined) {
    //            // 返回innerWidth/innerHeight
    //            return orig["inner" + name].call(this);
    //        }
    //        return this.each(function() {
    //            // 设置宽度/高度 = (size - padding)
    //            $(this).css(type, reduce(this, size) + "px");
    //        });
    //    };

    //    $.fn["outer" + name] = function(size, margin) {
    //        if ( typeof size !== "number") {
    //            // 返回outerWidth/outerHeight
    //            return orig["outer" + name].call(this, size);
    //        }
    //        return this.each(function() {
    //            // 设置宽度/高度 = (size - padding - border - margin)
    //            $(this).css(type, reduce(this, size, true, margin) + "px");
    //        });
    //    };
    //});

    // selectors
    function focusable(element, isTabIndexNotNaN) {
        var nodeName = element.nodeName.toLowerCase();
        if ("area" === nodeName) {
            var map = element.parentNode, mapName = map.name, img;
            if (!element.href || !mapName || map.nodeName.toLowerCase() !== "map") {
                return false;
            }
            img = $( "img[usemap=#" + mapName + "]" )[0];
            return !!img && visible(img);
        }
        return (/input|select|textarea|button|object/.test(nodeName) ? !element.disabled : "a" == nodeName ? element.href || isTabIndexNotNaN : isTabIndexNotNaN)
        // the element and all of its ancestors must be visible
        && visible(element);
    }

    function visible(element) {
        return !$(element).parents().andSelf().filter(function() {
            return $.curCSS(this, "visibility") === "hidden" || $.expr.filters.hidden(this);
        }).length;
    }


    $.extend($.expr[":"], {
        data : function(elem, i, match) {
            return !!$.data(elem, match[3]);
        },
        focusable : function(element) {
            return focusable(element, !isNaN($.attr(element, "tabindex")));
        },
        tabbable : function(element) {
            var tabIndex = $.attr(element, "tabindex"), isTabIndexNaN = isNaN(tabIndex);
            return (isTabIndexNaN || tabIndex >= 0 ) && focusable(element, !isTabIndexNaN);
        }
    });
    // support
    $(function() {
        var body = document.body, div = body.appendChild( div = document.createElement("div"));
        $.extend(div.style, {
            minHeight : "100px",
            height : "auto",
            padding : 0,
            borderWidth : 0
        });
        // 判断当前浏览器环境是否支持minHeight属性
        $.support.minHeight = div.offsetHeight === 100;
        $.support.selectstart = "onselectstart" in div;
        // set display to none to avoid a layout bug in IE
        // http://dev.jquery.com/ticket/4014
        body.removeChild(div).style.display = "none";
    });

    // deprecated
    $.extend($.ued, {
        // $.ued.plugin is deprecated.  Use the proxy pattern instead.
        plugin : {
            add : function(module, option, set) {
                var proto = $.ued[module].prototype;
                for (var i in set ) {
                    proto.plugins[i] = proto.plugins[i] || [];
                    proto.plugins[i].push([option, set[i]]);
                }
            },
            call : function(instance, name, args) {
                var set = instance.plugins[name];
                if (!set || !instance.element[0].parentNode) {
                    return;
                }
                for (var i = 0; i < set.length; i++) {
                    if (instance.options[set[ i ][0]]) {
                        set[ i ][1].apply(instance.element, args);
                    }
                }
            }
        }
    });

})(jQuery);

(function($, undefined) {
    // jQuery 1.4+
    if ($.cleanData) {
        var _cleanData = $.cleanData;
        $.cleanData = function(elems) {
            for (var i = 0, elem; ( elem = elems[i]) != null; i++) {
				try {
                	$(elem).triggerHandler("ued-remove");
				} catch( e ) {}
            }
            _cleanData(elems);
        };
    }

    $.uedWidget = function(name, base, prototype) {
        var namespace = name.split( "." )[0], fullName;
        name = name.split( "." )[1];
        fullName = namespace + "-" + name;
        // 例如参数name='ued.tabs'，变成namespace='ued',name='tabs',fullName='ued-tabs'
        // base默认为Widget类，组件默认会继承base类的所有方法
        if (!prototype) {
            prototype = base;
            base = $.UEDWidget;
        }
        // create selector for plugin
        $.expr[ ":" ][fullName] = function(elem) {
            return !!$.data(elem, name);
        };
        // 创建命名空间$.ued.tabs
        $[namespace] = $[namespace] || {};
        // 组件的构造函数
        $[ namespace ][name] = function(options, element) {
            // allow instantiation without initializing for simple inheritance
            if (arguments.length) {
                this._createWidget(options, element);
            }
        };
        // 初始化父类，一般调用了$.Widget
        var basePrototype = new base();
        // we need to make the options hash a property directly on the new instance
        // otherwise we'll modify the options hash on the prototype that we're
        // inheriting from
        //		$.each( basePrototype, function( key, val ) {
        //			if ( $.isPlainObject(val) ) {
        //				basePrototype[ key ] = $.extend( {}, val );
        //			}
        //		});
        basePrototype.options = $.extend(true, {}, basePrototype.options);
        // 给om.tabs继承父类的所有原型方法和参数
        $[ namespace ][name].prototype = $.extend(true, basePrototype, {
            namespace : namespace,
            widgetName : name,
            // 组件的事件名前缀，调用_trigger的时候会默认给trigger的事件加上前缀
            // 例如_trigger('create')实际会触发'tabscreate'事件
            widgetEventPrefix : $[ namespace ][name].prototype.widgetEventPrefix || name,
            widgetBaseClass : fullName
        }, prototype);
        // 把tabs方法挂到jquery对象上，也就是$('#tab1').tabs();
        var temp = $.uedWidget.bridge(name, $[ namespace ][name]);
    };

    $.uedWidget.bridge = function(name, object) {
        $.fn[name] = function(options) {
            // 如果tabs方法第一个参数是string类型，则认为是调用组件的方法，否则调用options方法
            var isMethodCall = typeof options === "string", args = Array.prototype.slice.call(arguments, 1), returnValue = this;
            // allow multiple hashes to be passed on init
            options = !isMethodCall && args.length ? $.extend.apply(null, [true, options].concat(args)) : options;
            // '_'开头的方法被认为是内部方法，不会被执行，如$('#tab1').tabs('_init')
            if (isMethodCall && options.charAt(0) === "_") {
                return returnValue;
            }
            if (isMethodCall) {
                this.each(function() {
                    // 执行组件方法
                    var instance = $.data(this, name);
                    if (options == 'options') {
                        returnValue = instance && instance.options;
                        return false;
                    } else {
                        var methodValue = instance && $.isFunction(instance[options]) ? instance[options].apply(instance, args) : instance;
                        if (methodValue !== instance && methodValue !== undefined) {
                            returnValue = methodValue;
                            return false;
                        }
                    }
                });
            } else {
                // 调用组件的options方法
                this.each(function() {
                    var instance = $.data(this, name);
                    if (instance) {
                        // 设置options后再次调用_init方法，第一次调用是在_createWidget方法里面。这个方法需要开发者去实现。
                        // 主要是当改变组件中某些参数后可能需要对组件进行重画
                        instance._setOptions(options || {});
                        $.extend(instance.options, options);
                        $(instance.beforeInitListeners).each(function() {
                            this.call(instance);
                        });
                        instance._init();
                        $(instance.initListeners).each(function() {
                            this.call(instance);
                        });
                    } else {
                        // 没有实例的话，在这里调用组件类的构造函数，并把构造后的示例保存在dom的data里面。注意这里的this是dom，object是模块类
                        $.data(this, name, new object(options, this));
                    }
                });
            }
            return returnValue;
        };
    };
    $.uedWidget.addCreateListener = function(name, fn) {
        var temp = name.split(".");
        $[ temp[0] ][temp[1]].prototype.createListeners.push(fn);
    };
    $.uedWidget.addInitListener = function(name, fn) {
        var temp = name.split(".");
        $[ temp[0] ][temp[1]].prototype.initListeners.push(fn);
    };
    $.uedWidget.addBeforeInitListener = function(name, fn) {
        var temp = name.split(".");
        $[ temp[0] ][temp[1]].prototype.beforeInitListeners.push(fn);
    };
    $.UEDWidget = function(options, element) {
        this.createListeners = [];
        this.initListeners = [];
        this.beforeInitListeners = [];
        // allow instantiation without initializing for simple inheritance
        if (arguments.length) {
            this._createWidget(options, element);
        }
    };
    /**
     * 格式化简单节点数据
     * add by ynshen
     */
    $.formatData = function(easyData, sourcePid) {
        var index;
        var root;
        //寻找根节点
        for (var i = 0; i < easyData.length; i++) {
            if (easyData[i].pid == sourcePid) {
                index = i;
                root = easyData[i];
                root.level = 0;
                break;
            }
        }
        if (root) {
            handleArray(easyData, root);
            return easyData[index];
        } else {
            return null;
        };
    }
    function handleArray(target_, pNode) {
        for (var i = 0; i < target_.length; i++) {
            if (target_[i].pid == pNode.id) {
                if (!pNode.children) {
                    pNode.children = new Array();
                }
                pNode.children.push(target_[i]);
                target_[i].level = pNode.level + 1;
                handleArray(target_, target_[i]);
            }
        }
    }

    /*=============================================*/
    $.UEDWidget.prototype = {
        widgetName : "widget",
        widgetEventPrefix : "",
        options : {
            disabled : false
        },
        _createWidget : function(options, element) {
            // $.widget.bridge stores the plugin instance, but we do it anyway
            // so that it's stored even before the _create function runs
            $.data(element, this.widgetName, this);
            this.element = $(element);
            this.options = $.extend(true, {}, this.options, this._getCreateOptions(), options);
            var self = this;
            //注意，不要少了前边的 "ued-"，不然会与jquery-ui冲突
            this.element.bind("ued-remove._" + this.widgetName, function() {
                self.destroy();
            });
            // 开发者实现
            this._create();
            $(this.createListeners).each(function() {
                this.call(self);
            });
            // 如果绑定了初始化的回调函数，会在这里触发。注意绑定的事件名是需要加上前缀的，如$('#tab1').bind('tabscreate',function(){});
            this._trigger("create");
            // 开发者实现
            $(this.beforeInitListeners).each(function() {
                this.call(self);
            });
            this._init();
            $(this.initListeners).each(function() {
                this.call(self);
            });
        },
        _getCreateOptions : function() {
            return $.metadata && $.metadata.get( this.element[0] )[this.widgetName];
        },
        _create : function() {
        },
        _init : function() {
        },
        destroy : function() {
            this.element.unbind("." + this.widgetName).removeData(this.widgetName);
            this.widget().unbind("." + this.widgetName);
        },
        widget : function() {
            return this.element;
        },

        option : function(key, value) {
            var options = key;
            if (arguments.length === 0) {
                // don't return a reference to the internal hash
                return $.extend({}, this.options);
            }
            if ( typeof key === "string") {
                if (value === undefined) {
                    return this.options[key];
                    // 获取值
                }
                options = {};
                options[key] = value;
            }
            this._setOptions(options);
            // 设置值
            return this;
        },
        _setOptions : function(options) {
            var self = this;
            $.each(options, function(key, value) {
                self._setOption(key, value);
            });
            return this;
        },
        _setOption : function(key, value) {
            this.options[key] = value;
            return this;
        },

        // $.widget中优化过的trigger方法。type是回调事件的名称，如"onRowClick"，event是触发回调的事件（通常没有这个事件的时候传null）
        // 这个方法只声明了两个参数，如有其他参数可以直接写在event参数后面
        _trigger : function(type, event) {
            // 获取初始化配置config中的回调方法
			/**
			  * add by ynshen
			  * 对于多层级的方法进行调用
			  */
            var callback;
			var callbackArr = type.split(".");
			
			if(callbackArr.length > 1){
				var tempCallback = this.options[callbackArr[0]];
				for(var i = 1 ;i < callbackArr.length;i++){
					tempCallback = tempCallback[callbackArr[i]]	;
				}
				callback = tempCallback;
			}else{
				callback = this.options[type]
			}
			
			
            // 封装js标准event对象为jquery的Event对象
            event = $.Event(event);
            event.type = type;
            // copy original event properties over to the new event
            // this would happen if we could call $.event.fix instead of $.Event
            // but we don't have a way to force an event to be fixed multiple times
            if (event.originalEvent) {
                for (var i = $.event.props.length, prop; i; ) {
                    prop = $.event.props[--i];
                    event[prop] = event.originalEvent[prop];
                }
            }
            // 构造传给回调函数的参数，event放置在最后
            var newArgs = [], argLength = arguments.length;
            for (var i = 2; i < argLength; i++) {
                newArgs[i - 2] = arguments[i];
            }
            if (argLength > 1) {
                newArgs[argLength - 2] = arguments[1];
            }
            return !($.isFunction(callback) && callback.apply(this.element, newArgs) === false || event.isDefaultPrevented() );
        }
    };
})(jQuery);


(function($) {
    /**
     * @name Dialog
     * @class 弹出框,可拖拽，设置宽和高，有无遮罩，
     */
    $.uedWidget('ued.Dialog', {
        options : /**@lends Dialog# */
        {
            /**
             *传入的标题
             * @type string
             * @default null
             * @example
             * $("#dialog").uedDialog({ title :"string"}})
             */
            title : null,
            /**
             *下端按钮，如果有数值，则添加，默认没有按钮
             * @type object
             * @default null
             * @example
             *  $("#dialog").uedDialog({buttons:["false":function(){
             *     alert(2)
             * },"true":function(){
             *     alert(3)
             * }]})
             */
            buttons : null,
            /**
             *是否有遮罩，添加在body下,默认有
             * @type boolean
             * @default true
             * @example
             *  $("#dialog").uedDialog({modal:false})
             */
            modal : false,
            /**
             *定位,如果没有传入默认居中,以百分比为单位
             * @type object
             * @default null
             * @example
             * $("#dialog").uedDialog({position:[50,10]})
             */
            position : null,
            /**
             *dialog的宽度
             * @type int
             * @default 300
             * @example
             *  $("#dialog").uedDialog({width:500})
             */
            width : 300,
            /**
             *dialog的高度
             * @type int
             * @default 200
             * @example
             * $("#dialog").uedDialog({height:500})
             */
            height : 200,
            /**
             *是否可以拖拽
             * @type boolean
             * @default true
             * @example
             *  $("#dialog").uedDialog({isDrag:false})
             */
            isDrag : true,
            /**
             *默认打开
             * @type boolean
             * @default false
             * @example
             *  $("#dialog").uedDialog({autoOpen:false})
             */
            autoOpen : false,
            /**
             *提示类型"success","error","confirm","warning"
             * @type string
             * @default null
             * @example
             * $("#dialog").uedDialog({type:"success"})
             */
            type : null,
            /**
             *提示信息
             * @type string
             * @default null
             * @example
             * $("#dialog").uedDialog({message:"tishixingxing"})
             */
            message: null,
            /*
			 * type:confirm时,点击确定按钮的回调
			 */
            confirmCallback:null,
			/*
			 * 弹窗关闭后的回调,默认为null
			 */
			closeCallback : null,
            /*
             * 弹窗的定位方式，默认为true  
             */
            fixed:true
        },
       
        _create: function () {
            var mescope = this;
            if ($('body').width() == 0) {//当在页面a中用异步tab加页面b的iframe时，如果页面b中有pfTable,parent的宽度是0，结果是表头和body都不是100%，表头靠左，body水平居中--wxj20181218
                //console.info('wait');
                setTimeout(function () {
                    mescope._create.call(mescope);
                }, 100);
                return;
            }
            var $el = this.element, options = this.options, self = this;
            //debugger;
            //当弹窗宽高过大时(由于桌面分辨率太小所致),自动缩小弹窗--wxj20180719
            if (typeof options.width === 'string') { options.width = parseInt(options.width.replace('px', '')); }
            if (typeof options.height === 'string') { options.height = parseInt(options.height.replace('px', '')); }
            var ww = $(window).width() - 100;
            var wh = $(window).height() - 100;
            if (options.width > ww) { options.width = ww; }
            if (options.height > wh) { options.height = wh; }

            var _define = this._define = {};
			//创建弹窗节点
			this._createDialogDom($el, options, _define);
			//设置弹窗属性
			this._calDialogAttr($el, options, _define);
			//绑定弹窗事件
			this._bindEvent($el, options, _define);
        },
       
	    _createDialogDom : function($el, options, _define){
			var $farther = _define.$farther = $el.parent(), buttons = options.buttons;
			var $dialog = _define.$dialog = $('<div class="ui-dialog-panel"><div class="ui-dialog"></div><div class="ui-dialog-leftYY"></div><div class="ui-dialog-rightYY"></div><div class="ui-dialog-bottomLeft"></div><div class="ui-dialog-bottomRight"></div><div class="ui-dialog-bottomCenter"></div></div>');
			//创建弹窗头部区域
			var $dialogHd = _define.$dialogHd = $('<div class="ui-dialog-hd"><h6></h6><a href="javascript:;" class="ui-dialog-close ue-state-default"><i></i></a></div>');
			//创建弹窗内容区域
			var $dialogContent = _define.$dialogContent = $el.addClass('ui-dialog-content');
	        //由于ui-dialog-bottomCenter 有bottom: -13px; 导致其和 ui-dialog 之间有空隙,能看穿--wxj20180930
			$dialog.css('backgroundColor','white');
			if(options.type){
				//创建提示型弹窗提示区域
				this._createMessageDom($el, $dialogContent, options);
			}else{
				//普通型弹窗内为iframe时，拖动卡顿
			    if ($el.children().is('iframe')) {
					var $contentMask = _define.$contentMask = $('<div style="position:absolute;top:45px;left:0;right:0;bottom:0;display:none"></div>');
					$dialogContent.append($contentMask);
				} else {
				    $dialogContent.css('overflow', 'auto');//当内容过高时，父中的内容穿透上来了，倒不如让里面滚动--wxj20180724
				}
			}
			$el.css('display','block');//显示$el内容
			
			$dialog.children('.ui-dialog').append($dialogHd).append($dialogContent);
			//创建弹窗底部区域
			var $dialogFt = _define.$dialogFt = $('<div class="ui-dialog-ft"></div>');
			if(buttons){
				var buttonArray = [];
				for(var i = 0, len = buttons.length; i < len; i++){
					var button = buttons[i], length = this._returnLetterLength(button.label);
					length = length < 3 ? 3 : length;
					if(button.recommend){
						buttonArray.push('<button type="button" class="ue-button-recommend ue-state-default long' + length + '">'+ button.label +'</button>');
					}else{
						buttonArray.push('<button type="button" class="ue-button ue-state-default long' + length + '">'+ button.label +'</button>');
					}
				}
				$dialogFt.append(buttonArray.join(''));
			    //$dialog.children().append($dialogFt);
				$dialog.children('.ui-dialog').append($dialogFt);
			}
			
			//判断是否需要生成遮罩
			//if(!options.modal){
			if (options.modal) {//原版的意思是当modal为true时不创建dragMask,在open时用$.mask.open(),但实测没效果,于是改为open时直接显示dragMask--wxj20180525
                //var $dragMask = _define.$dragMask = $('<div style="position: fixed;z-index:9999;top:0;left:0;right:0;bottom:0;display:none"></div>');
			    var $dragMask = _define.$dragMask = $('<div class="diagMask" style="position: fixed;z-index:9999;top:0;left:0;right:0;bottom:0;display:none;width:100%;height:100%;background-color:black;opacity: 0.3;"></div>');//原版没背景色的mask没起作用
           		 $('body').append($dragMask);
			}
			
			//插入到$farther中去
			$farther.append($dialog.hide());
		},
		/*
		 * 创建提示型弹窗提示区域
		 */
		_createMessageDom : function($el, $dialogContent, options){
			var type = options.type, _define = this._define;
			
			_define.$dialog.addClass('ui-dialog-'+type);
		    //创建节点
			if (options.type === 'confirm') {
			    //加confirm的确认取消按钮--wxj20180524
			    var str =
                '<div class="ui-dialog-icon"></div><div class="ui-dialog-text">' +
                    '<p class="dialog-content"><span class="dialog-text"></span></p>' +
                    '<p class="tips">如果是请点击“确定”，否则点“取消”</p>' +
                    '<br />' +
                    '<div class="buttons">' +
                        '<input type="button" class="button long2 ok" value="确定" />&nbsp;' +
                        '<input type="button" class="button long2 normal" value="取消" />' +
                    '</div>'+
			    '</div>';
			    $dialogContent.empty().append(str);
			} else {
                $dialogContent.empty().append('<div class="ui-dialog-icon"></div><div class="ui-dialog-text"><span class="patch"></span><span class="dialog-text"></span></div>');//原版
			}

			var $dialogMessage = _define.$dialogMessage = $dialogContent.find('.dialog-text');
		},
		
		_calDialogAttr : function($el, options, _define){
			
			this.setTitle(options.title);
			if(!options.type){
				//普通弹窗
				this.setWidth(options.width);
				this.setHeight(options.height);
			} else {
			    //提示型弹窗
			    this.setWidth(options.width);
			    this.setHeight(options.height);
			    //this.setWidth(355);
			    //this.setHeight(145);
			    //this.setWidth(400 > options.width?options.width:400);//原本355的宽度放不下,导致ui-dialog-text换行了.option.width是根据iframe的宽度调整过的--wxj20180523
			    //this.setHeight(145 > options.height ? options.height : 145);
			    if (400 > options.width) {
			        $el.find('div.ui-dialog-text').css('width', (options.width-136)+'px');//当窗口宽度小于400时,文字会换行,所以要缩小text宽度(text如果不设置宽度,直接就换行了).136是左边logo的宽度
                }
				this.setMessage(options.message);
			}
			//设置弹窗的位置
			this.setPosition(options.position);
			
			if(options.autoOpen){
				this.open();
			}
		},
		
		_calLeft : function(_left, _define){
			if(_left == 'left'){
				_define.left = 0;
			} else {
			    //_define.left = ($(window).width() - _define.width) / 2;
			    _define.left = ($(window).width() - _define.$dialog.width()) / 2;//原版的_define.width是undefined--wxj20180525
				_define.left = _define.left < 0 ? 0 : _define.left;
			}
		},
		
		_calTop : function(_top, _define){
			if(_top == 'top'){
				_define.top = 0;
			}else{
			    //_define.top = ($(window).height() - _define.height) / 2;
			    _define.top = ($(window).height() - _define.$dialog.height()) / 2;//原版的_define.height是undefined--wxj20180525
				_define.top = _define.top < 0 ? 0 : _define.top;
			}
		},
		
		_bindEvent : function($el, options, _define){
			var self = this;
			//绑定关闭按钮事件
			_define.$dialogHd.children('.ui-dialog-close').click(function(){
				self.close();
			});
			
			//绑定弹窗拖拽事件
			if(options.isDrag){
				self._dialogDrag(self, _define);
			}
			//绑定按钮点击事件
			var buttons = options.buttons;
			if(buttons){
				_define.$dialogFt.bind('click',function(e){
					var $target = $(e.target), button = buttons[$target.index()];
					if($target.is('button')){
						if(!button.setFunc){
							button.callBack && button.callBack(self.element, $('#__mask',$('body')));
						}else{
							button.callBack && button.callBack(button.param);
							self.close();
						}
					}
				});
			}
			if (options.type === 'confirm') {
			    //debugger;
			    _define.$dialogContent.find('input.ok').bind('click', function (e) {
			        options.confirmCallback.call(self);
			        self.close();
			    });
			    //_define.$dialogContent.find('input.ok').click(function (e) {
			    //    options.confirmCallback.call(self.element);
			    //    //debugger;
			    //    //options.confirmCallback();
			    //    self.close();
			    //});
			    _define.$dialogContent.find('input.normal').bind('click', function (e) {
                    self.close();
			    });
            }
		},
		/*
		 * 弹窗拖动函数
		 * @param {Object} self 弹窗对象
		 * @param {Object} _define组件内部自定义对象。用来存放临时值 
		 */
		_dialogDrag : function(self, _define){
			var $dragMask = _define.$dragMask, $contentMask = _define.$contentMask;
			var $dialogHd = _define.$dialogHd, $dialog = _define.$dialog, winWidth, winHeight;
			var left,top,dialogWidth = _define.width, dialogHeight = _define.height;
			var tempX, tempY;
			$dialogHd.css('cursor','move');
			$dialogHd.bind('mousedown', function (e) {
			    dialogHeight = _define.height;//重新获得高--benjamin20190428
				//e.preventDefault();
				//获取最新值
				left = _define.left, top = _define.top, tempX = e.clientX, tempY = e.clientY, winWidth = $(window).width(), winHeight = $(window).height();

				if(!self.options.fixed){//定位为absolute
					winHeight = $(document).outerHeight();
				}
				$contentMask && $contentMask.show();
				//$dragMask && $dragMask.show();
				$dragMask && $dragMask.css('opacity',0.4);//open时已打开,这里改为修改透明度--wxj20180525
				this.setCapture && this.setCapture();
				$(document).bind('mousemove',mouseMove).bind('mouseup',mouseUp);
			});	
			
			var mouseMove = function(e){
				_define.left = e.clientX - tempX + left;
				_define.top = e.clientY - tempY + top;
				_define.left = _define.left < 0 ? 0 : _define.left > (winWidth - dialogWidth) ? (winWidth - dialogWidth) : _define.left;
				_define.top = _define.top < 0 ? 0 : _define.top > (winHeight - dialogHeight) ? (winHeight - dialogHeight) : _define.top;
				$dialog.css({'left':_define.left,'top':_define.top});
			}
			var mouseUp = function(e){
				this.releaseCapture && this.releaseCapture();
				$contentMask && $contentMask.hide();
				//$dragMask && $dragMask.hide();
				$dragMask && $dragMask.css('opacity', 0.3);
				$(document).unbind('mousemove',mouseMove).unbind('mouseup',mouseUp);
			}
		},
		
		/*
		 * 给弹窗设置标题。
		 * @param {String or Object} _title 弹窗标题
		 */
		setTitle : function(_title){
			var _define = this._define, $dialogHd = _define.$dialogHd;
			if(_title){
				$dialogHd.find('h6').empty().append('<span class="dialog-hd-lc"></span>' + _title + '<span class="dialog-hd-rc"></span>');
			}
		},
		
		/*
		 * 给弹窗设置宽度
		 * @param {int} _width 弹窗宽度
		 */
		setWidth : function(_width){
			var _define = this._define, $dialogContent = _define.$dialogContent;
			$dialogContent.width(_width);
			//存储弹窗宽度，以便后期计算位置
			_define.width = $dialogContent.outerWidth() + 10;
		},
		
		/*
		 * 给弹窗设置高度
		 * @param {int} _height 弹窗高度
		 */
		setHeight : function(_height){
			var _define = this._define, $dialogContent = _define.$dialogContent;
			$dialogContent.height(_height);
			//存储弹窗高度，以便后期计算位置
			_define.height = $dialogContent.outerHeight() + 50;
		},
		/*
		 * 给提示型弹窗设置提示信息
		 * @param {String or Object} _message 提示弹窗的提示信息
		 */
		setMessage : function(_message){
			if(!_message) return;
			var _define = this._define, $dialogMessage = _define.$dialogMessage;
			$dialogMessage.empty().append(_message);
		}, 
		/*
		 * 设置弹窗的位置
		 */
		setPosition : function(_position){
			if(!_position){
				_position = ['center','center'];
			}
			var _define = this._define ,left = _position[0], top = _position[1], options = this.options;
			_define.left = left, _define.top = top;
			if(typeof left != 'number'){
				//计算弹窗的left值
				this._calLeft(left, _define);
			}
			
			if(typeof top != 'number'){
			    //计算弹窗的left值
			    this._calTop(top, _define);
			}
			
			//赋值给弹窗
			if(options.fixed){
				_define.$dialog.css({'position':'fixed','left':_define.left,'top':_define.top});
			}else{
				_define.$dialog.css({'position':'absolute','left':_define.left,'top':_define.top});	
			}
		},
		
		open: function () {
			var _define = this._define, $dialog = _define.$dialog , options = this.options, isMask = options.modal;	
		    //isMask && $.mask.open('ued-dialog');
			isMask && _define.$dragMask.show();//上句报错--wxj20180525
			if(!options.fixed && options.position[1]=='center'){
				//如果弹窗不是fiexd定位，且top为center时，打开前需要+scrollTop
				_define.top += $(window).scrollTop();
				$dialog.css('top',_define.top);
			}
			$dialog.show();
		},
		
		close : function(){
		    var _define = this._define, $dialog = _define.$dialog, closeCallback = this.options.closeCallback, isMask = this.options.modal;
			//isMask && $.mask.close('ued-dialog');
			isMask && _define.$dragMask.hide();//上句报错--wxj20180525
			$dialog.hide();
			closeCallback && closeCallback.call(this.element, this.element, $('#__mask', $('body')));
			if($pf!==undefined&&typeof $pf.clearIframe == 'function'){$pf.clearIframe(_define.$dialogContent.children('iframe'));}//如果不清除iframe,下次打开时会显示旧内容--wxj20181023
			this.element.trigger('popupsClosed');
			//alert('popupsClosed');
		},
        _init : function() {
           // var self = this, options = this.options, $el = this.element;
        },
		_returnLetterLength : function(_str){
			return _str.replace(/[a-z0-9]{2}/ig,'a').length;	
		},
		remove : function(){
			this._define.$dialog.remove();	
			$.mask.close('ued-dialog');
			this._define = null;
		},
		/*
         * 用于修改第一个button的默认函数 addBy xzjiang,update rbai
         * @param {Object} _func 函数体
         * @param {string} _param
		 */
        setFunc : function(_func, _param) {

            var self = this, options = this.options, firstButton = options.buttons[0];
			firstButton.callBack = _func;
			firstButton.param = _param;
			firstButton.setFunc = true;
        }
    });
})(jQuery);

(function($) {
	/**
	 * select 下拉选择框渲染组件
	 * author: yswang
	 * version: 1.0
	 */
	$.fn.iSelect = function(){
		return this.each(function () {
        	var _iSel = new $.iSelect(this);
        	_iSel = null;
   	 	});
	};

	$.iSelect = function( select ){
		if( !select || select.multiple ){
			return false;
		}
		
		var isel_id = select.id;
		if( !isel_id || isel_id === "" || typeof isel_id == "undefined" ){
			isel_id = "iSel-"+Math.round( Math.random()*10000 );
			select.id = isel_id;
		}
		if( document.getElementById("_iSelWrap_"+ isel_id) ){
			return false;
		}
		
		var $select = $(select), sel_w = select.offsetWidth;
		$select.addClass("iselect");
		var _onchange = select.onchange;
		
		if( sel_w >= 500 ){
			sel_w = 500;
		}
		
		var isel_wrap = '<div id="_iSelWrap_'+isel_id+'" class="iselect-wrapper"></div>';
		var isel_wrapin = '<span id="_iSelVal_'+isel_id+'" class="iselwrap-val"></span>';
		
		// 包裹select
		$select.wrap( isel_wrap );
		$("#_iSelWrap_"+ isel_id).append( isel_wrapin );

		var iSel_val = $("#_iSelVal_"+ isel_id);
		
		select.onchange = null;
		$select.change(function () {
		    //console.info(1);
			var _val = this.options[this.selectedIndex].text;
			iSel_val.text( _val );
			
			// 执行可能存在的原始onchange事件
			if( _onchange && typeof _onchange != "undefined" ){
				_onchange.apply(this);
			}
		});
		
		// 初始下显示select默认值
		var sel_option = $select.find("option:selected").first();
		if( sel_option.length <= 0 ){
			sel_option = $select.find("option:first");
		}
		
		iSel_val.text( sel_option.text() );   

		var $isel_wrap = $("#_iSelWrap_" + isel_id);
		var w = $select.width();//根据select的宽度设置外层宽度,参照原框架原则:E:\svn\businessSys2018\yjquery.Web\Content\static\system\my_info.html 选地址的宽度
		if (w !== null && w !== undefined) {
		    //$isel_wrap.width(w - 27);
		    $isel_wrap.width(w - 20);//当页面控件的宽度设为auto时,发现原本减的27太大了,会换行.20为.iselect-wrapper上的padding-right--wxj20181017
		}

        //在原生对象中加入此方法来改变select的选项--wxj20180817
		select.selectOption = function (value, text) {
		    var _text = '';
		    if (value !== null && value !== undefined) {
		        $select.val(value);
		        _text=$select.find("option[value="+value+"]").text();
		    } else {
		        var _val = $select.find("option").filter(function () { return $(this).text() === text; }).val();
		        $select.val(_val);
		        _text = text;
		    }
		    iSel_val.text(_text);
		};
        //替换原生的empty方法--benjamin20190927
		select.pfEmpty = function (emptyText) {
		    $select.empty();
		    $("#_iSelVal_" + isel_id).text(emptyText||'');
		};
	};
	
})(jQuery);
function setSelectVal(selectId,val){
	$("#_iSelVal_"+ selectId).text(val);
}
jQuery.fn.pagination = function (maxentries, opts) {
    opts = jQuery.extend({
        items_per_page: 10, // 每页显示多少条记录
        current_page: 0,      //当前页码
        num_display_entries: 4, // 中间显示页码的个数
        num_edge_entries: 2, // 末尾显示页码的个数
        link_to: "javascript:;",         //页码点击后的链接
        prev_text: "&lt;&nbsp;上一页",   //上一页的文字
        next_text: "下一页&nbsp;&gt;",	   //下一页的文字
        ellipse_text: "...",  //页码之间的省略号
        display_msg: true, // 是否显示记录信息
        prev_show_always: true, //是否总是显示最前页
        next_show_always: true,//是否总是显示最后页
        setPageNo: false,//是否显示跳转第几页
        callback: function () {
            return false;
        } // 回调函数
    }, opts || {});

    return this.each(function () {
        // 总页数
        function numPages() {
            return Math.ceil(maxentries / opts.items_per_page);
        }
        /**
		 * 计算页码
		 */
        function getInterval() {
            var ne_half = Math.ceil(opts.num_display_entries / 2);
            var np = numPages();
            var upper_limit = np - opts.num_display_entries;
            var start = current_page > ne_half ? Math.max(Math.min(current_page
									- ne_half, upper_limit), 0) : 0;
            var end = current_page > ne_half ? Math.min(current_page + ne_half,
					np) : Math.min(opts.num_display_entries, np);
            return [start, end];
        }

        /**
		 * 点击事件
		 */
        function pageSelected(page_id, evt) {
            var page_id = parseInt(page_id);
            current_page = page_id;
            drawLinks();
            var continuePropagation = opts.callback(page_id, panel);
            if (!continuePropagation) {
                if (evt.stopPropagation) {
                    evt.stopPropagation();
                } else {
                    evt.cancelBubble = true;
                }
            }
            return continuePropagation;
        }

        /**
		 * 链接
		 */
        function drawLinks() {
            panel.empty();
            $pagin.empty();
            panel.append($pagin);
            var interval = getInterval();
            var np = numPages();
            var getClickHandler = function (page_id) {
                return function (evt) {
                    return pageSelected(page_id, evt);
                }
            }
            var appendItem = function (page_id, appendopts) {
                page_id = page_id < 0 ? 0 : (page_id < np ? page_id : np - 1);
                appendopts = jQuery.extend({
                    text: page_id + 1,
                    classes: ""
                }, appendopts || {});
                if (page_id == current_page) {
                    var lnk = $("<span class='current'>" + (appendopts.text)
							+ "</span>");
                } else {
                    var lnk = $("<a>" + (appendopts.text) + "</a>").bind(
							"click", getClickHandler(page_id)).attr('href',
							opts.link_to.replace(/__id__/, page_id));

                }
                if (appendopts.classes) {
                    lnk.addClass(appendopts.classes);
                }
                $pagin.append(lnk);
            }
            // 上一页
            if (opts.prev_text && (current_page > 0 || opts.prev_show_always)) {
                appendItem(current_page - 1, {
                    text: opts.prev_text,
                    classes: "prev"
                });
            }
            // 点点点
            if (interval[0] > 0 && opts.num_edge_entries > 0) {
                var end = Math.min(opts.num_edge_entries, interval[0]);
                for (var i = 0; i < end; i++) {
                    appendItem(i);
                }
                if (opts.num_edge_entries < interval[0] && opts.ellipse_text) {
                    jQuery("<span>" + opts.ellipse_text + "</span>")
							.appendTo($pagin);
                }
            }
            // 中间的页码
            for (var i = interval[0]; i < interval[1]; i++) {
                appendItem(i);
            }
            // 最后的页码
            if (interval[1] < np && opts.num_edge_entries > 0) {
                if (np - opts.num_edge_entries > interval[1]
						&& opts.ellipse_text) {
                    jQuery("<span>" + opts.ellipse_text + "</span>")
							.appendTo($pagin);
                }
                var begin = Math.max(np - opts.num_edge_entries, interval[1]);
                for (var i = begin; i < np; i++) {
                    appendItem(i);
                }

            }
            // 下一页
            if (opts.next_text
					&& (current_page < np - 1 || opts.next_show_always)) {
                appendItem(current_page + 1, {
                    text: opts.next_text,
                    classes: "next"
                });
            }
            // 记录显示
            if (opts.display_msg) {
                if (!maxentries) {
                    panel
						.append('<div class="pxofy">暂时无数据可以显示</div>');
                } else {
                    panel
                            .append('<div class="pxofy">显示第&nbsp;'
                                    + ((current_page * opts.items_per_page) + 1)
                                    + '&nbsp;条到&nbsp;'
                                    + (((current_page + 1) * opts.items_per_page) > maxentries
                                            ? maxentries
                                            : ((current_page + 1) * opts.items_per_page))
                                    + '&nbsp;条记录，总共&nbsp;' + maxentries + '&nbsp;条</div>');
                }
            }
            //设置跳到第几页
            if (opts.setPageNo) {
                $("<div class='goto'><span class='text'>转到第</span><input type='text'/><span class='page'>页</span><a href='javascript:;'>转</a></div>").insertBefore($pagin);
            }
        }

        // 当前页
        var current_page = opts.current_page;
        maxentries = (maxentries < 0) ? 0 : maxentries;
        opts.items_per_page = (!opts.items_per_page || opts.items_per_page < 0)
				? 1
				: opts.items_per_page;
        var panel = jQuery(this),
			$pagin = $('<div class="pagin-list"></div>');


        this.selectPage = function (page_id) {
            pageSelected(page_id);
        }
        this.prevPage = function () {
            if (current_page > 0) {
                pageSelected(current_page - 1);
                return true;
            } else {
                return false;
            }
        }
        this.nextPage = function () {
            if (current_page < numPages() - 1) {
                pageSelected(current_page + 1);
                return true;
            } else {
                return false;
            }
        }

        if (maxentries == 0) {
            panel.append('<span class="current prev">' + opts.prev_text + '</span><span class="current next">' + opts.next_text + '</span><div class="pxofy">暂时无数据可以显示</div>');
        } else {
            drawLinks();
        }
        $(this).find(".goto a").on("click", function (evt) {
            var setPageNo = $(this).parent().find("input").val();
            if (setPageNo != null && setPageNo != "" && setPageNo > 0 && setPageNo <= numPages()) {
                pageSelected(setPageNo - 1, evt);
            }
        });
    });
};//这里有了分号,否则有问题--wxj20180511

/*
* table组件扩展
* opts属性说明：
* button 自定义按钮，数组，如 [{text:,action:},'excel']
* selectMode:0不能选择 1单选 2多选,默认0,我增加的属性--benjamin
* rowDrag:bool 行可拖动排序--benjamin20190430
*/
jQuery.fn.pfTable = function (opts) {//设置DataTables组件的一些属性,要先引用相关资源--wxj20180515
    var me = this;
    var $pfTable = me;
    $pfTable.addClass('stripe');//当bAutoWidth为false时，有奇偶行样式(多了display这个class名)，但当为true时display这个class名没有加进入，原因未明.不过stripe也是DataTables自带样式，利用了--wxj20180830
    var result = {};
    result.tableApi = null;

    opts=opts||{};
    var hasSummary = false;
    var paginationOpts = null;
    var showPagination =opts.showPagination!==false;
    var selectMode = opts.selectMode || 0;
    var selectable = selectMode !== 0;
    var rowDrag = opts.rowDrag || false;//行可拖动排序,其实全部可拖也没什么影响--benjamin20190430
    //if (opts.pagination !== null && opts.pagination !== undefined) {
    //    paginationOpts = jQuery.extend({
    //        id: '',
    //        pageIndex: 0,
    //        pageSize: 10
    //    }, opts.pagination || {});
    //    delete opts.pagination;
    //    //showPagination =true;
    //}
    if (showPagination) {
        paginationOpts = jQuery.extend({
            id: $pfTable[0].id+'-pagin',
            pageIndex: 0,
            pageSize: 10
        }, opts.pagination || {});
        delete opts.pagination;
        //showPagination =true;
        if($('#'+paginationOpts.id).length<1){
            $pfTable.after($('<div id="' + paginationOpts.id + '" class="pagination"></div>'));
        }
    }
    var _url = '';//调用loadUrl()时赋值(不包含pageIndex和pageSize参数)
    var _lastSort = '';//因为每次draw都触发order,所以自行判断
    var _lastFilterValue = '';
    var _hasGroupBtn = false;
    var _cacheKey = opts.cacheKey;
    //var privateObj = {};//私有变量
    var userLoadOpts = {};//用户调用loadUrl方法后需要保存的参数--benjamin20190419

    function bindCellClick() {
        for (var i in opts.onCellClick) {
            if (opts.onCellClick.hasOwnProperty(i)) {
                $pf.bindTableColumnClick(me, i, opts.onCellClick[i]);
            }
        }
    }
    var $headTable = {};

    //function exchangeRow(row1, row2) {//交换行
    //    var data = result.tableApi.row(row1).data();
    //    //var nextRow = rows.parent().children()[idx - 1];
    //    //var nextIds = result.tableApi.row(row2).index();
    //    var nextData = result.tableApi.row(row2).data();

    //    result.tableApi.row(row2).data(data);
    //    result.tableApi.row(row1).data(nextData);
    //}

    function fixSelect(body,cur, isSelected) {
        var tr = body.find('tr:eq(' + cur + ')');
        if (isSelected) {
            body.find('tr input.pf-row-select:eq(' + cur + ')').prop("checked", true);
            if (!tr.hasClass('selected')) {
                tr.addClass('selected');
            }
        } else {
            if (tr.hasClass('selected')) {
                tr.removeClass('selected');
            }
        }
    }
    //orders,如:[3,1,2]
    result.orderRow = function (sOrders) {
        var body = $pfTable.find('tbody');
        var maxIdx = body.find('tr').length - 1;
        if (sOrders.length !== (maxIdx + 1)) { return; }

        var orders = [];
        //for (var i = 0; i < sOrders.length; i++) {//输入参数有可能是string[],但需要的是int[]
        //    orders.push(typeof sOrders[i] === 'string' ? parseInt(sOrders[i]) : sOrders[i]);
        //}

        var oldRows = [];//[{selected:true,}]只存Data
        var selected = [];
        for (var i = 0; i <= maxIdx; i++) {
            //debugger;
            orders.push(typeof sOrders[i] === 'string' ? parseInt(sOrders[i]) : sOrders[i]);//输入参数有可能是string[],但需要的是int[]

            //var oi = typeof orders[i] === 'string' ? parseInt(orders[i]) : orders[i];
            var row = body.find('tr:eq(' + i + ')');
            if (orders[i] !== i) {//有变动才赋值,增加性能
                oldRows.push(result.tableApi.row(row[0]).data());
            } else {
                oldRows.push({});
            }
            if (selectable) {
                selected.push(row.find('input.pf-row-select').is(':checked'));
            }
        }
        for (var i = 0; i <= maxIdx; i++) {
            if (orders[i] !== i) {//有变动才赋值,增加性能
                var row = body.find('tr:eq(' + i + ')');
                result.tableApi.row(row[0]).data(
                    oldRows[orders[i]]
                );
                fixSelect(body, i, selected[orders[i]]);
            }
        }
        //for (var i = 0; i <= maxIdx; i++) {
        //    fixSelect(body,i, selected[i]);
        //}
    };
    function insertRow(srcRowIdx, dstRowIdx) {//src插到dst后面(如果这个方法维护麻烦,可以简接调用result.orderRow)
        var body = $pfTable.find('tbody');
        var srcRow = body.find('tr:eq(' + srcRowIdx + ')');
        var srcData = result.tableApi.row(srcRow[0]).data();
        var cur = srcRowIdx;
        var maxIdx = body.find('tr').length-1;
        if (maxIdx < srcRowIdx) { return; }
        if (maxIdx < dstRowIdx) { dstRowIdx = maxIdx; }

        var selected = [];
        if (selectable) {//调换行时,选择的checkbox会清掉
            while (cur !== dstRowIdx) {
                var next = cur + (srcRowIdx > dstRowIdx ? -1 : 1);

                selected.push(body.find('tr input.pf-row-select:eq(' + cur + ')').is(':checked'));
                cur = next;
            }
            //for (var i = srcRowIdx; i <= dstRowIdx; i++) {
            //    selected.push(body.find('tr input.pf-row-select:eq(' + i + ')').is(':checked'));
            //}
        }
        selected.push(body.find('tr input.pf-row-select:eq(' + dstRowIdx + ')').is(':checked'));

        //console.info(selected);
        var cur = srcRowIdx;
        var i = 0;
        while (cur !== dstRowIdx) {
            var next = cur + (srcRowIdx > dstRowIdx ? -1 : 1);
            //下一行的数据填到cur行;
            result.tableApi.row(body.find('tr:eq(' + cur + ')')[0]).data(
                result.tableApi.row(body.find('tr:eq(' + next + ')')[0]).data()
            );
            if (selectable) {
                fixSelect(body,cur, selected[i + 1]);
                i++;
            }
            //console.info(cur);
            cur = next;
        }
        ////src填到dst行
        result.tableApi.row(body.find('tr:eq(' + dstRowIdx + ')')[0]).data(
            srcData
        );
        if (selectable) {
            fixSelect(body,dstRowIdx, selected[0]);
        }
    }
    var defaultDrawCallback = function () {
        //if (selectMode ===0) {
        //    me.find("tbody tr:odd").css("backgroundColor", "#eff6fa");//奇偶行样式,直接写在dom上优先级太高,选择行的样式都不生效，改为复写odd的背景色好了--wxj20180830
        //    me.find("tbody tr:even").css("backgroundColor", "white");
        //}
        me.find('tbody tr td.text-right').css("text-align", "right");//网上建议createdRow fnRowCallback (https://bbs.csdn.net/topics/391050901)

        //修复一个bug,当无数据时再变为有数据,这里虽然加了tfoot但初始化后没有去掉no-footer这个类导致多了个border-bottom(最好以后看看api对象时的foot属性是不是在destroy后并没有重置)
        if (hasSummary) {
            var $wrapper = $('#' + $pfTable[0].id + '_wrapper');
            var headInner = $wrapper.find('div.dataTables_scrollHeadInner table.dataTable');
            if (headInner.hasClass('no-footer')) {
                headInner.removeClass('no-footer');
            }
            var footInner = $wrapper.find('div.dataTables_scrollFootInner table.dataTable');
            if (footInner.hasClass('no-footer')) {
                footInner.removeClass('no-footer');
            }
            var scrollBody = $wrapper.find('div.dataTables_scrollBody table.dataTable');
            if (scrollBody.hasClass('no-footer')) {
                scrollBody.removeClass('no-footer');
            }
        }
        bindCellClick();

        if (selectable){
            $headTable = $pfTable.parent().parent().find('.dataTables_scrollHead table');
            if($headTable.attr('selectAllBinded')!=='true'){
                $headTable.on('click', 'thead tr input.pf-row-select-all', function (e) {
                    $headTable.attr('selectAllBinded', 'true');
                    //alert(1);
                    $pf.stopPropagation(e);
                    //debugger;
                    var b = $(this).is(':checked');
                    //if (b === true) {

                    //}
                    var cbs = $pfTable.find('tbody tr input.pf-row-select');
                    cbs.each(function (index, element) {
                        var cb = $(element);
                        if (cb.is(':checked') !== b) { cb.click(); }
                    });

                });
            }
        }
        //搜索栏改为后端
        var searchF = $pfTable.parents('.dataTables_wrapper').find('.dataTables_filter input[type=search]');
        //debugger;
        searchF.unbind();
        searchF.change(function () {
            //alert(this.value);
            _lastFilterValue = this.value;
            //var lastFilterValue = this.value;
            var url = $pf.setUrlParams(_url, { filterValue: this.value });
            //var tmpOpts = jQuery.extend({ needSetLastFilterValue: true }, userLoadOpts);
            result.sysLoadUrl(url, { needSetLastFilterValue: true });

            //不用下面ajax方式的原因是,如果后面无数据时返回了false,DataTable会报错
            //var url = result.tableApi.ajax.url($pf.setUrlParams(_url, { PageSize: opts.pagination.pageSize, PageIndex: 0, sort: _lastSort ,filterValue:this.value}));
            //url.load(function (data) {
            //    ////debugger;
            //    //if (selectMode === 2) {
            //    //    $headTable.find('thead tr input.pf-row-select-all').prop("checked", false);
            //    //}
            //    bindPaging(data.total, 0);
            //    //searchF.val(_lastFilterValue);
            //});
        });

        if (rowDrag) {
            function allowDrop(ev) {
                ev.preventDefault();
            }
            function drag(ev) {
                var idx = $(ev.target).parent().find('tr').index(ev.target);
                //ev.originalEvent.dataTransfer.setData("dragRowIdx", idx);
                ev.originalEvent.dataTransfer.setData("Text", idx.toString());//ie中,第一个参数必需为Text,第二个必需为String
            }
            function drop(ev) {
                ev.preventDefault();
                //var dragRowIdx = parseInt(ev.originalEvent.dataTransfer.getData("dragRowIdx"));
                var dragRowIdx = parseInt(ev.originalEvent.dataTransfer.getData("Text"));
                var dragRow = $pfTable.find('tbody tr:eq(' + dragRowIdx + ')');
                var targetRow = $(ev.target).parent('tr');
                var targetRowIdx = targetRow.parent().find('tr').index(targetRow);
                if (dragRowIdx === targetRowIdx) {
                    //console.info('相同');
                } else {
                    insertRow(dragRowIdx, targetRowIdx);
                    //exchangeRow(dragRow, targetRow);
                }
            }
            $pfTable.find('tbody tr').attr('draggable', true)
            .on('dragover', allowDrop)
            .on('dragstart', drag)
            .on('drop', drop);
        }
        //debugger;
        if(_hasGroupBtn){
            $pf.post('GetGroupColumnCache', { cacheKey: _cacheKey }, function (data) {
                //var cbx = me.parent().parent().parent().find('.dt-buttons span').filter(function () { return $(this).text().indexOf("设置汇总列") > -1; })
                //    .find('input[type=checkbox]');
                var cbx = me.parents('.dataTables_wrapper').find('.dt-buttons span').filter(function () { return $(this).text().indexOf("设置汇总列") > -1; })
                    .find('input[type=checkbox]');//之前3个parent的方式不准确,在有锁定列时会多一层--benjamin20191009
                if (data.Result) {
                    cbx.prop("checked", true);
                } else {
                    cbx.prop("checked", false);
                }
            });
        }
    };
    //debugger;
    var drawCallback = null;
    if (typeof opts.drawCallback == 'function') {
        var userDrawCallback = opts.drawCallback;
        drawCallback = function () {
            var drawMe = this;
            defaultDrawCallback();
            userDrawCallback.call(drawMe);
        }
        delete opts.drawCallback;
    } else {
        drawCallback =defaultDrawCallback;
    }

    //var buttons = $pf.getTableToolbar(opts);
    var buttons = [];
    var excelBtn={
        text: '导出Excel', action: function (event) {
            var url = _url;
            if (url[0] !== '/') {//如果是相对地址,要转为绝对地址
                url = window.location.pathname.replace(/[^/]*$/, url)
            }
            url = $pf.setUrlParams(url, { sort: _lastSort, filterValue: _lastFilterValue });
            $pf.exporter({
                title: null,
                dataAction: url
            })
            .download($(event.currentTarget).attr("suffix"))
            ;
        }
    };
    var addBtn = {
        text: '新增', alwayShow:true,action: function (event) {
            $pfTable.trigger('tbar.add');
        }
    };
    var editBtn = {
        text: '修改', action: function (event) {
            var rows = result.getSelectedRows();
            if (rows.length=== 1) {
                $pfTable.trigger('tbar.edit', [result.tableApi.row(rows[0]).data()]);
            } else {
                $pf.warningPopups("请选择一行");
            }

            //var data = result.tableApi.row('.selected').data();
            //if (data === null || data === undefined){
            //    $pf.warningPopups("请选择一行"); return;
            //}
            //$pfTable.trigger('tbar.edit', [data]);
        }
    };
    var deleteBtn = {
        text: '删除', action: function (event) {
            var data = [];
            var rows = result.getSelectedRows();
            if (rows.length > 0) {
                for (var i = 0; i < rows.length; i++) {
                    data.push(result.tableApi.row(rows[i]).data());
                }
                $pf.confirmPopups('确定删除吗?'+(data.length>1?'数量:'+data.length:''), function () {
                    $pfTable.trigger('tbar.delete', [data]);//删除时应该是可以多选的,所以data是数组
                });
            } else {
                $pf.warningPopups("请选择需要删除的行"); 
            }

            //var data = result.tableApi.row('.selected').data();
            //if (data === null || data === undefined) {
            //    $pf.warningPopups("请选择一行"); return;
            //}
            //$pf.confirmPopups('确定删除吗?', function () {
            //    $pfTable.trigger('tbar.delete', [data]);
            //});
        }
    };
    var setVisibleColumnBtn = {
        text: '设置显示列', action: function (event) {
            var url = _url;
            if (url[0] !== '/') {//如果是相对地址,要转为绝对地址
                url = window.location.pathname.replace(/[^/]*$/, url)
            }
            $pf.setVisibleColumnPopups({ dataAction: url });
        }
    };
    var setGroupColumnBtn = {
        text: '设置汇总列<input type="checkbox" />', action: function (event) {
            var url = _url;
            if (url[0] !== '/') {//如果是相对地址,要转为绝对地址
                url = window.location.pathname.replace(/[^/]*$/, url)
            }
            $pf.setGroupColumnPopups({
                dataAction: url, cacheType: 'GroupColumn',cacheKey:_cacheKey,
                listeners: {
                    colSetted: function () {
                        result.sysLoadUrl(_url);
                    }
                }
            });
        }
    };
    //debugger;
    if (opts.buttons instanceof Array) {
        for (var i = 0; i < opts.buttons.length; i++) {
            switch (opts.buttons[i].Name) {
                case 'Export':
                case 'excel':
                    buttons.push(excelBtn);
                    break;
                case 'Add':
                    buttons.push(addBtn);
                    break;
                case 'Edit':
                    buttons.push(editBtn);
                    break;
                case 'Delete':
                    deleteBtn.text = opts.buttons[i].Text;
                    buttons.push(deleteBtn);
                    break;
                case 'SetVisibleColumn':
                    buttons.push(setVisibleColumnBtn);
                    break;
                case 'SetGroupColumn':
                    setGroupColumnBtn.alwayShow = setGroupColumnBtn.AlwayShow;
                    buttons.push(setGroupColumnBtn);
                    _hasGroupBtn = true;
                    break;
                default:
                    (function ( name,text,alwayShow) {//注意action会有作用域的问题
                        buttons.push({
                            text: text,
                            alwayShow:alwayShow,
                            action: function (event) {
                                //debugger;
                                var data = [];
                                var rows = result.getSelectedRows();
                                if (rows.length > 0) {
                                    for (var i = 0; i < rows.length; i++) {
                                        data.push(result.tableApi.row(rows[i]).data());
                                    }
                                }
                                //var data = result.tableApi.row('.selected').data();
                                $pfTable.trigger('tbar.' + name, [data]);
                            }
                        });
                    }(opts.buttons[i].Name, opts.buttons[i].Text, opts.buttons[i].AlwayShow));
                    //var name = opts.buttons[i].Name;
                    //buttons.push({
                    //    text: opts.buttons[i].Text,
                    //    action: function (event) {
                    //        //debugger;
                    //        var data = [];
                    //        var rows = result.getSelectedRows();
                    //        if (rows.length > 0) {
                    //            for (var i = 0; i < rows.length; i++) {
                    //                data.push(result.tableApi.row(rows[i]).data());
                    //            }
                    //        }
                    //        //var data = result.tableApi.row('.selected').data();
                    //        $pfTable.trigger('tbar.' + name, [data]);
                    //    }
                    //});
                    break;
            }
        }
        //delete opts.buttons;
    } else {
        //buttons = [excelBtn];
        buttons = [];
    }
    delete opts.buttons;
    //debugger;
    var defaultOpts = jQuery.extend({
        "language": {
            search: "搜索:",
            sZeroRecords: "没有找到匹配的记录"
        },
        destroy: true,
        pagination: paginationOpts,
        paging: false,
        info: false,
        //scrollY: true,
        scrollX: true,
        order: [],
        drawCallback: drawCallback
    }, opts || {});
    if (buttons.length > 0) { defaultOpts.buttons = buttons; defaultOpts.dom = 'Bfrtip'; }

    function newOpts() {
        var r = jQuery.extend({}, defaultOpts);
        if (r.order instanceof Array) {
            r.order=r.order.slice(0);//数组型的成员要这样才不会因opts改变而改变
        }
        return r;
    }
    opts = newOpts();

    function bindPaging(total, current) {//绑定分页组件
        //if (showPagination) {
            paging = $('#' + opts.pagination.id).pagination(total, {
                items_per_page:opts.pagination.pageSize,
                current_page: current,
                callback: function (page) {
                    opts.pagination.pageIndex = page;
                    //var url = result.tableApi.ajax.url(_url + "&PageSize=" + opts.pagination.pageSize + "&PageIndex=" + page + "&sort=" + _lastSort);
                    var url = result.tableApi.ajax.url($pf.setUrlParams(_url, { PageSize: opts.pagination.pageSize, PageIndex: page, sort: _lastSort, filterValue: _lastFilterValue }));
                    url.load(function () {
                        //if (selectMode===2) {
                        //    $headTable.find('thead tr input.pf-row-select-all').prop("checked", false);
                        //}
                        bindPaging(total, page);
                    });
                },
                display_msg: true,
                setPageNo: true
            });
                if (selectMode === 2) {
                    $headTable.find('thead tr input.pf-row-select-all').prop("checked", false);

                    if (opts.fixedColumns !== undefined && opts.fixedColumns !== false) {//如果有锁定列时
                        $pfTable.parent().parent().parent().find('.DTFC_LeftWrapper .DTFC_LeftHeadWrapper table.dataTable tr th input.pf-row-select-all').prop("checked", false);
                    }
                }
                if (!$pf.stringIsNullOrWhiteSpace(_lastFilterValue)) {
                    var searchF = $pfTable.parents('.dataTables_wrapper').find('.dataTables_filter input[type=search]');
                    searchF.val(_lastFilterValue);
                }
        //}
        //bindCellClick();
    }
    result.loadCurrentPage = function (loadOpts) {//刷新当前页(编辑数据后使用)
        var url = result.tableApi.ajax.url($pf.setUrlParams(_url, { PageSize: opts.pagination.pageSize, PageIndex: opts.pagination.pageIndex, sort: _lastSort, filterValue: _lastFilterValue, random: Math.random() }));
        url.load(function (data) {
            if (loadOpts !== null && loadOpts !== undefined && typeof loadOpts.success == 'function') {
                loadOpts.success(data);
            }
            bindPaging(data.total, opts.pagination.pageIndex);
        });
    };
    result.getSelectedRows = function () {
        return $pfTable.find('tbody tr.selected');
    };
    function getHeaderTR(lists, maxDepth, currentDepth) {
        if(currentDepth==null||currentDepth==undefined){currentDepth=1;}
        var writer="";
        if (lists != null)
        {
            //显示下一层
            var next = [];
            //显示头
            for (var idx=0;idx< lists.length;idx++)
            {
                var i=lists[idx];
                writer += getHeaderTD(i, maxDepth, currentDepth);

                if (i.Children != null) {//下一层数据
                    for (var j = 0; j < i.Children.length; j++) {
                        next.push(i.Children[j]);
                    }
                }
            }

            if (next.length > 0)
            {
                writer += "</tr>";
                writer += "<tr>";
                writer += getHeaderTR(next, maxDepth, ++currentDepth);
            }
        }
        return writer;
    }
    function getHeaderTD(item, maxDepth, currentDepth) {
        var writer = "";
        var title = item.data || item.title;//合并列用中文,其它列要对应data
        //if (title === null || title === undefined || title === '') { return; }
        item._columnSpan = 1;
        item._rowSpan = 1;
        var style = "";
        //debugger;
        //if (item.Children != null && item.Children != undefined && item.Children.length > 1)
        if (item.Children != null && item.Children != undefined && item.Children.length > 0)//大于0才是对的--wxj20180906
        {
            item._columnSpan = $pf.getAllLeafCount(item); 
        } else {
            style+="border-bottom: 1px solid #111;";//最后一个th加下加框--wxj20180716
            if (maxDepth > currentDepth)
            {
                item._rowSpan = maxDepth - currentDepth + 1;
            }
        }
        if (!$pf.stringIsNullOrWhiteSpace(item.width)) { style += "width=" + item.width+";"; }
        if (!$pf.stringIsNullOrWhiteSpace(style)) { style = " style='" + style + "' "; }
        //if (!Visible) { style = "style=' display:none' "; }
        var attrs = "";
        if (item.data !== null && item.data !== undefined) { attrs += " field-name='" + item.data + "' "; }

        if (item.isSelectAllCol) {
            if (selectMode === 1) { title = "选择"; }
            else if (selectMode === 2) { title = "<input type='checkbox' class='pf-row-select-all' />全选"; }
        }
        writer += $pf.formatString("<th {1} {2} {3} {4}>{0}</th>", title, item._columnSpan > 1 ? ("colspan=" + item._columnSpan) : "", item._rowSpan > 1 ? ("rowspan=" + item._rowSpan) : "", style, attrs);

        return writer;
    }
    function setLastFilterValue() {
        //这里必需重新找组件,因为loadUrl时重新生成了search组件
        $pfTable.parents('.dataTables_wrapper').find('.dataTables_filter input[type=search]')
            .val(_lastFilterValue);//因为loadUrl是页面共用的,理应把过滤器的值清掉,所以这里要重新赋值
    }
    result._loadUrl = function (url, loadOpts) {
        var mescope = this;
        //if ($('body').width() == 0) {//当在页面a中用异步tab加页面b的iframe时，如果页面b中有pfTable,parent的宽度是0，结果是表头和body都不是100%，表头靠左，body水平居中--wxj20181218
        //debugger;
        if ($('body').width() == 0 || $pfTable.parent().width() <11) {//以前的版本在"批量增加用户"功能(使用了TabContainer)仍然不能自动设置autoWidth--ben20190529
            //console.info('wait');
            setTimeout(function () {
                result._loadUrl.call(mescope, url, loadOpts);
            }, 100);
            return;
        }
        loadOpts = loadOpts || {};
        //var toUrl = url + "&PageIndex=0";        
        var toUrlParams = { PageIndex: 0 };
        if (showPagination) {
            //toUrl += "&PageSize=" + opts.pagination.pageSize;
            toUrlParams.PageSize = opts.pagination.pageSize;
        }
        toUrl = $pf.setUrlParams(url, toUrlParams);
        var layerIdx = layer.load('正在查询请稍候');
        $pf.post(toUrl, null, function (data) {
            //debugger;
            $pfTable = me;
            if (data && data.Result !== false && typeof data !== 'string') {//MvcMenuFilter拦截后直接返回了文字--wxj20181127
                if (result.tableApi !== null && data.columns !== null) {
                    //alert('destroy');
                    result.tableApi.destroy();
                    $(me).empty();
                }
                //debugger;
                //opts.pagination.url = url;
                _url = url;
                if (data.columns !== null || result.tableApi === null) {//列数据有更新时
                    opts = newOpts();
                    opts.data = data.data;
                    if (data.columns !== null) {
                        var treeColumn = { Children: data.columns };
                        //为了生成多表头,需要拼接<thead>
                        var thead = "<thead><tr>";
                        if (selectable) {
                            data.columns.splice(0, 0, {
                                isSelectAllCol: true,
                                orderable: false,
                                width: '15px',
                                Children: [],
                                render: function () {
                                    return '<input type="checkbox" class="pf-row-select"  />';
                                }
                            });
                        }

                        thead += getHeaderTR(data.columns, $pf.getDepth(treeColumn) - 1);
                        thead += "</tr></thead>";
                        //debugger;
                        $(thead).appendTo($pfTable);
                        //汇总信息
                        var foot = '';
                        hasSummary = false;

                        var columns = [];

                        $pf.eachLeaf(treeColumn, function (i) {
                            if (i.dataType === 'decimal' || i.dataType === 'int' || i.dataType === 'long' || i.dataType === 'double') {
                                if (i.className === null || i.className === undefined) { i.className = ''; }
                                i.className += ' text-right';
                                i.render = function (data, type, row) {
                                    return $pf.thousandth(data);
                                }
                            }
                            if (i.dataType === 'percent') {
                                //debugger;
                                if (i.className === null || i.className === undefined) { i.className = ''; }
                                i.className += ' text-right';
                                i.render = function (data, type, row) {
                                    return $pf.stringIsNullOrWhiteSpace(data) ? '' : ($pf.thousandth($pf.toFixed(data)) + ' %');
                                }
                            }
                            if (i.dataType === 'DateTime') {
                                i.render = function (data, type, row) {
                                    return $pf.formatTime(data, 'yyyy-MM-dd hh:mm:ss');
                                }
                            }
                            if (i.dataType === 'date') {
                                i.render = function (data, type, row) {
                                    return $pf.formatDate(data);
                                }
                            }
                            if (i.dataType === 'bool') {
                                i.render = function (data, type, row) {
                                    return data === true ? "是" : "否";
                                }
                            }

                            if (i.summary !== null && i.summary !== undefined) {
                                if (!hasSummary) {
                                    foot = foot.replace(/<th><\/th>$/, '<th style="text-align:right">Total:</th>');
                                }
                                hasSummary = true;
                                var h = typeof i.render === 'function' ? i.render(i.summary) : i.summary;
                                foot += '<th style="text-align:right">' + h + '</th>';
                            } else {
                                foot += '<th></th>';
                            }
                            //if (i.width !== null && i.width !== undefined) {//后台返回42px,到table时,内部只有36--benjamin20190716
                            //    i.width = (parseFloat(i.width.replace('px')) + 6).toString() + 'px';
                            //}
                            columns.push(i);
                        });
                        opts.columns = columns;

                        if (hasSummary) {
                            $($('<tfoot>' +
                                    '<tr>' + foot +
                                    '</tr>' +
                                '</tfoot>')).appendTo($pfTable);

                        }
                        //bindEvent();
                        //alert('create with column');
                    }
                    else {
                        //alert('create without column');
                    }
                    result.tableApi = $pfTable.DataTable(opts);
                    //console.info($pfTable.width());
                    //console.info($pfTable.parent().width());
                    if ($pfTable.width() < $pfTable.parent().width()) {//默认自动调列宽。当table的宽度小于容器和分页器时，如果用自动，会变得很窄，所以设置为不自动，然后利用css设置宽度为100%

                        opts.bAutoWidth = false;
                        result.tableApi = $pfTable.DataTable(opts);

                    }
                    //console.info("bAutoWidth = " + opts.bAutoWidth);
                    //console.info($pfTable.width());
                    //console.info($pfTable.parent().width());
                    //console.info($('body').width());
                    //console.info('----------------');
                } else {//列数据无更新时
                    result.tableApi.clear();
                    for (var i = 0; i < data.data.length; i++) {
                        result.tableApi.row.add(data.data[i]);
                    }
                    //alert('reload rows');
                    result.tableApi.draw();
                }
                if (showPagination) {
                    opts.pagination.pageIndex = 0;
                    bindPaging(data.total, 0);//如果不重新绑定,总页数不会改变,当前页也不会置为0
                    $('#' + opts.pagination.id).show();
                }

                if (typeof loadOpts.success == 'function') {//complete回调一般后续使用data更新其它dom
                    loadOpts.success(data);
                    //privateObj.userLoadSuccess = loadOpts.success;
                }
                if (loadOpts.needSetLastFilterValue) {
                    setLastFilterValue();
                }
                //if (typeof loadOpts.sysLoadSuccess == 'function') {
                //    loadOpts.sysLoadSuccess(data);
                //}
                ////$('#' + opts.pagination.id).show();
            } else {

                if (result.tableApi !== null) {
                    result.tableApi.destroy();
                    $(me).empty();
                }
                var message = "没有数据";
                if (typeof data === 'string') { message = data; }
                else if (data && data.Message) { message = data.Message; }
                $(me).html('<thead><tr><th>提示</th></tr></thead><tbody><tr onclick="$pf.stopPropagation(arguments[0])"><td  onclick="$pf.stopPropagation(arguments[0])">' + message + '</td></tr></tbody>');
                var alwayBtns = [];
                //debugger;
                for (var i = 0; i < buttons.length; i++) {
                    if (buttons[i].alwayShow === true) {
                        alwayBtns.push(buttons[i]);
                    }
                }
                //debugger;
                var nullOpts = { paging: false, info: false, searching: false };
                if (alwayBtns.length > 0) { nullOpts.buttons = alwayBtns; nullOpts.dom = 'Bfrtip'; }
                result.tableApi = me.DataTable(nullOpts);
                if (showPagination) { $('#' + opts.pagination.id).hide(); }

            }
            if (layerIdx) { layer.close(layerIdx); }
            if (typeof loadOpts.complete == 'function') {//complete回调一般用于mask的状态控制,重新更新列宽等
                loadOpts.complete();
            }
        });
    };
    result.loadUrl = function (url, loadOpts) {//为了便于导出,url请用完整地址.load时更新分页组件的属性.不要想把批量上传的文件放这里，因为如果每次都上传文件会很慢的,也不要把hybhs拼接到url上(url太长也会报错),只能后台用session保存,然后传进来;loadOpts不应改为系统变量
        _lastFilterValue = '';
        _lastSort = '';
        userLoadOpts = loadOpts;
        result._loadUrl(url, loadOpts);
    };
    result.sysLoadUrl = function (url, loadOpts) {//Table内部使用
        loadOpts = jQuery.extend(loadOpts, userLoadOpts);
        result._loadUrl(url, loadOpts);
    };
            //debugger;
    if (selectMode == 1 || selectMode == 2) {
        result.selectRow = function (tr) {
            if (tr.hasClass('selected')) {
                tr.removeClass('selected');
                tr.find('input.pf-row-select').prop("checked", false);
            }
            else {
                if (selectMode == 1) {
                    var trs = result.tableApi.$('tr.selected');
                    var cbs = trs.find('input.pf-row-select');
                    cbs.prop("checked", false);
                    trs.removeClass('selected');
                }
                tr.addClass('selected');
                tr.find('input.pf-row-select').prop("checked", true);
            }
        };
        $pfTable.on('click', 'tbody tr input.pf-row-select', function (e) {
            $pf.stopPropagation(e);
            //debugger;
            var tr = $(this).parent().parent();
            var tempTb=tr.parent().parent();
            if (tempTb.attr('id') !== $pfTable.attr('id')) {//如果有锁定列时,点击锁定列时进入这里
                var idx = tr.parent().find('tr').index(tr);//行序号
                $pfTable.find('tbody tr:nth-child(' + (idx + 1) + ')').click();
                return;
            } 

            if (opts.fixedColumns !== undefined && opts.fixedColumns !== false) {//如果有锁定列时,点击普通列进入这里
                var idx = tr.parent().find('tr').index(tr);//行序号
                //$pfTable.parent().parent().parent().find('.DTFC_LeftWrapper table.dataTable tr:nth-child(' + (idx + 1) + ') input.pf-row-select').prop("checked", false);
                result.selectRow($pfTable.parent().parent().parent().find('.DTFC_LeftWrapper .DTFC_LeftBodyWrapper table.dataTable tr:nth-child(' + (idx + 1) + ') '));
            }

            result.selectRow(tr);
            //if (tr.hasClass('selected')) {
            //    tr.removeClass('selected');
            //}
            //else {
            //    if (selectMode == 1) {
            //        var trs = result.tableApi.$('tr.selected');
            //        var cbs = trs.find('input.pf-row-select');
            //        cbs.prop("checked", false);
            //        trs.removeClass('selected');
            //    }
            //    tr.addClass('selected');
            //}
        });
        $pfTable.on('click', 'tbody tr', function (e) {
            $pf.stopPropagation(e);
            $(this).find('input.pf-row-select').click();
            //var cbs =$(this).find('input.pf-row-select');
            ////cbs.prop("checked", true);
            //cbs.click();
        });
    }

    var _isOrdering = false;
    $pfTable.on('order.dt', function (e) {//注意，这里的datatables原生排序事件不仅在点表头时会触发，draw后也会触发
        // This will show: "Ordering on column 1 (asc)", for example
        if (result.tableApi) {
            //debugger;
            $pf.stopPropagation(e);
            var order = result.tableApi.order();
            if (order.length > 0) {
                var sort = result.tableApi.column(order[0][0]).dataSrc() + "%20" + order[0][1];
                if (_lastSort === sort) { return; }                
                if (_isOrdering === true) { return; }
                _isOrdering = true;
                //var url = _url + "&sort=" + sort;//当_url没有?号时直接加&会使地址错误--benjamin20190430
                var url = $pf.setUrlParams(_url, { sort: sort });
               
                if (showPagination) { url += "&PageSize=" + opts.pagination.pageSize + "&PageIndex=" + opts.pagination.pageIndex;}
                $pf.post(url, null, function (data) {
                //$pf.post(getPagingUrl(), null, function (data) {
                    if (data && data.Result !== false && data.data!==undefined) {
                        result.tableApi.clear();
                        for (var i = 0; i < data.data.length; i++) {
                            result.tableApi.row.add(data.data[i]);
                        }
                        opts.order = [[order[0][0], order[0][1]]];
                        result.tableApi.draw();
                        setLastFilterValue();//benjamin20190419
                        //result.tableApi.order([order[0], order[1]]);
                    }
                    _isOrdering = false;
                    _lastSort = sort;
                });
                //var param = $("#f1").serialize();
                //tableApi.loadUrl("GetData?" + param + "&sort=" + tableApi.tableApi.column(order[0]).dataSrc() + "%20" + order[0][1]);
            }
            //alert('Ordering on column ' + order[0][0] + ' (' + order[0][1] + ')');
            return false;
        }
        //$('#orderInfo').html('Ordering on column ' + order[0][0] + ' (' + order[0][1] + ')');
    });
    result.isRowSelectAll = function () {
        return $headTable.find('thead tr input.pf-row-select-all').is(':checked');
    };
    //result.rowMoveUp = function () {//已经实现拖放移动--benjamin20190429
    //    var rows = result.getSelectedRows();
    //    if (rows.length === 1) {
    //        //table.data().length
    //        var idx=result.tableApi.row(rows[0]).index();
    //        if (idx === 0) {
    //            $pf.warningPopups("第一行不能上移");
    //        }
    //        exchangeRow(rows[0], rows.parent().children()[idx - 1]);
    //        rows.find('input.pf-row-select').prop("checked", true);

    //        //var data = result.tableApi.row(rows[0]).data();
    //        //var nextRow = rows.parent().children()[idx - 1];
    //        //var nextIds = result.tableApi.row(nextRow).index();
    //        //var nextData = result.tableApi.row(nextRow).data();
            
    //        //result.tableApi.row(nextRow).data(data);
    //        //result.tableApi.row(rows[0]).data(nextData);
    //        ////alert(idx);
    //        ////alert(nextIds);
    //        ////$pfTable.trigger('tbar.edit', [result.tableApi.row(rows[0]).data()]);
    //    } else {
    //        $pf.warningPopups("请选择一行");
    //    }
    //};
    return result;
};

/*
*fixedColumns:int 锁定列
*/
jQuery.fn.pfTreeTable = function (opts) {
    var me = this;
    var $pfTable = me;
    //var $headTable = {};
    //var selector = me.selector;
    me.addClass('pfTreeGrid');
    var _url = '';//调用loadUrl()时赋值(不包含pageIndex和pageSize参数)
    var _colIdxs = [];//保存多表头的列信息,为了不用多次循环生成,有改变时更新
    _colIdxs = $pf.getTableColumnIdxs(me);

    opts = opts || {};
    //var hasSummary = false;
    //var paginationOpts = null;
    //var showPagination = opts.showPagination !== false;
    var selectMode = opts.selectMode || 0;
    var selectable = selectMode !== 0;
    var closeTree = opts.closeTree  || false;

    function bindCellClick() {
        for (var i in opts.onCellClick) {
            if (opts.onCellClick.hasOwnProperty(i)) {
                //$pf.bindTableColumnClick(me.selector, i, opts.onCellClick[i]);
                var idx = _colIdxs.indexOf(i);
                //debugger;
                if (idx !== null && idx !== undefined) {
                    me.on('click', 'tbody tr td:nth-child(' + (idx + 1) + ')', function (e) {
                        //debugger;
                        //alert('x');
                        if (!($(e.target).hasClass('hitarea'))) {
                            opts.onCellClick[i].call(this, e);
                            //opts.onCellClick[i](e);
                        }
                    });
                    //var $cell = me.find(' tbody tr td:nth-child(' + (idx + 1) + ')');
                    //$cell.unbind('click', opts.onCellClick[i]);
                    //$cell.bind('click', opts.onCellClick[i]);
                    //$cell.css('textDecoration', 'underline');
                    //$cell.css('cursor', 'pointer');
                }
            }
        }
    }
    function bindCellClickCss() {
        for (var i in opts.onCellClick) {
            if (opts.onCellClick.hasOwnProperty(i)) {
                var idx = _colIdxs.indexOf(i);
                if (idx !== null && idx !== undefined) {
                    var $cell = me.find(' tbody tr td:nth-child(' + (idx + 1) + ')');
                    //$cell.unbind('click', opts.onCellClick[i]);
                    //$cell.bind('click', opts.onCellClick[i]);
                    $cell.css('textDecoration', 'underline');
                    $cell.css('cursor', 'pointer');
                }
            }
        }
    }
    bindCellClick();
    function setOddEvenRowCss(tbody) {
        //tbody.find("tr:odd").css("backgroundColor", "#eff6fa");//奇偶行样式
        //tbody.find("tr:even").css("backgroundColor", "white");
        $pf.setOddEvenRowCss(tbody);
        //var odd = true;
        //tbody.find('tr').each(function () {
        //    var tr = $(this);
        //    if (odd) {
        //        tr.removeClass('even').addClass('odd');
        //    } else {
        //        tr.removeClass('odd').addClass('even');
        //    }
        //    odd != odd;
        //});
    }
    //function resetFixedColumnWidth() {
    //    if (opts.fixedColumns !== undefined && opts.fixedColumns !== false) {
    //        var thead = me.find('thead');

    //        //取消注释--benjamin 
    //        $pf.copyTableHeadWidth(thead, $('#'+me[0].id +'-fixedColumn thead'), true);
    //        $pf.copyTableHeadWidth(thead, $('#'+me[0].id +'-fixedCorner thead'), true);
    //        $pf.copyTableHeadWidth(thead, $('#'+me[0].id +'-fixedhead thead'));
    //    }

    //}
    function resetFixedColumnSize() {
        if (opts.fixedColumns !== undefined && opts.fixedColumns !== false) {
            var thead = me.find('thead');

            //取消注释--benjamin 
            $pf.copyTableHeadSize(thead, $('#'+me[0].id +'-fixedColumn thead'), true);
            $pf.copyTableHeadSize(thead, $('#'+me[0].id +'-fixedCorner thead'), true);
            $pf.copyTableHeadSize(thead, $('#'+me[0].id +'-fixedhead thead'));
        }

    }
    var defaultDrawCallback = function () {
        bindCellClickCss();

        ////fixedColumns: {
        ////        leftColumns: 2
        ////}
        ////alert(1);
        if (opts.fixedColumns !== undefined && opts.fixedColumns !== false//如果有锁定列时
            ) {
            $('#' + me[0].id + '-fixedColumn').remove();
            $('#' + me[0].id + '-fixedhead').remove();
            $('#' + me[0].id + '-fixedCorner').remove();

            if (me.find('thead tr').length <1//当显示"无相关数据"时
                ) {
                return;
            }
            
            //取消display:none --benjamin 
            var fixedColumnTable = $('<table id="' + me[0].id + '-fixedColumn" class="pfTreeColumnGrid" style="position:absolute;top:0px;left:0px;"></table>');
            var fixedHeadTable = $('<table id="' + me[0].id + '-fixedhead" style="position:absolute;top:0px;left:0px;"></table>');
            var fixedCornerTable = $('<table id="' + me[0].id + '-fixedCorner" style="position:absolute;top:0px;left:0px;"></table>');
            function setFixedPosition() {
                var l = me.parent()[0].scrollLeft + 'px';
                var t = me.parent()[0].scrollTop + 'px';
                //console.info(l);
                //console.info(t);
                fixedColumnTable.css('left',l);
                fixedHeadTable.css('top',t );
                fixedCornerTable.css('left', l);
                fixedCornerTable.css('top', t);
            }

            var fixedColumns = opts.fixedColumns && typeof opts.fixedColumns == 'number' ? opts.fixedColumns : 1;
            if (selectable) { fixedColumns += 1;}
            //fixedColumns = 2;
            var fixedHeader = $('<thead></thead>');
            var fixedBody = $('<tbody></tbody>');
            var headTr = me.find('thead tr:eq(0)');//现时没有考虑锁定列是多表头的情况,如果以后有了,可以增加 curRowNum:[2,1,0]解决,每个int代表当前列是到第几行了
            //var headTr = me.find('thead tr');
            //var width = 0;
            //var headRowSpan = headRowSpan.find('tr').length;
            for (var i = 0; i < headTr.length; i++) {
                var tmpTr = $('<tr class="pfGridHead"></tr>');
                for (var j = 0; j < fixedColumns; j++) {
                    var tmpTh = headTr.find('th:eq('+j+')');
                    //tmpTh.attr('rowSpan', headRowSpan);
                    //width = tmpTh.width();
                    var cloneTh = tmpTh.clone(true);
                    var rect = tmpTh[0].getBoundingClientRect();
                    //cloneTh.css('lineHeight', (
                    //    rect.height
                    //    - 1
                    //    - parseInt(tmpTh.css('paddingTop').replace('px'))
                    //    - parseInt(tmpTh.css('paddingBottom').replace('px'))
                    //    ) + 'px');//不要设置lineHeight,换行时太宽--benjamin20190711
                    cloneTh.css('height', (
                        rect.height
                        - 1
                        - parseInt(tmpTh.css('paddingTop').replace('px'))
                        - parseInt(tmpTh.css('paddingBottom').replace('px'))
                        ) + 'px');//
                    cloneTh.css('padding', '10px 18px');
                    cloneTh.css('background', 'none');
                    cloneTh.css('backgroundColor', '#E8F1F7');
                    //debugger;
                    $pf.copyDomBorder(tmpTh, cloneTh);
                    //cloneTh.css('borderRight', tmpTh.css('borderRight'));
                    tmpTr.append(cloneTh);

                    (function (idx, jdx) {//注意action会有作用域的问题
                        cloneTh.click(function (e) {
                            $pf.stopPropagation(e);
                            //debugger;

                            if ($(e.target).hasClass('pf-row-select-all')) {
                                me.find('thead tr th:nth-child(' + (jdx + 1) + ') .pf-row-select-all').eq(idx).trigger('click');

                                $pf.stopPropagation(e);
                                return;
                            } else {
                                me.find('thead tr th:nth-child(' + (jdx + 1) + ')').eq(idx).trigger('click');
                            }
                        });
                    }(i, j));
                }
                tmpTr.appendTo(fixedHeader);
            }
            //fixedHeader.find('tr td .pf-row-select-all').click(function () {

            //});

            function setFixedColumnWidth() {
                var thead = me.find('thead');

                //取消注释--benjamin 
                $pf.copyTableHeadWidth(thead, fixedHeader,true);
                $pf.copyTableHeadWidth(thead, fixedCornerTable.find('thead'),true);
                $pf.copyTableHeadWidth(thead, fixedHeadTable.find('thead'));

            }

            var bodyTr = me.find('tbody tr');
            for (var i = 0; i < bodyTr.length; i++) {
                var tmpTr = $('<tr></tr>');
                var bodyTrI=bodyTr.eq(i);
                tmpTr.css('display', bodyTrI.css('display'));
                if (bodyTrI.attr('expanded') === 'expanded') { tmpTr.attr('expanded','expanded');}
                if (bodyTrI.hasClass('selected')) { tmpTr.addClass('selected');}
                
                for (var j = 0; j < fixedColumns; j++) {
                    var srcTh = bodyTrI.find('td:eq('+j+')');
                    var tmpTh = srcTh.clone(true);
                    //debugger;
                    tmpTh.css('textDecoration', srcTh.css('textDecoration'));
                    tmpTh.css('cursor', srcTh.css('cursor'));

                    tmpTr.append(tmpTh);
                    (function (idx,jdx) {//注意action会有作用域的问题
                        tmpTh.click(function (e) {
                            $pf.stopPropagation(e);
                            //debugger;
                            if ($(e.target).hasClass('hitarea')) {
                                //alert(1);
                                //debugger;
                                $pf.expandTree($(e.target).parent());

                                //me.find('tbody tr td:nth-child(1) .hitarea').eq(idx).trigger('click');
                                //me.find('tbody tr td:nth-child(' + (selectable ? 2 : 1) + ') .hitarea').eq(idx).trigger('click');
                                me.find('tbody tr td:nth-child(' + (jdx + 1) + ') .hitarea').eq(idx).trigger('click');

                                $pf.stopPropagation(e);
                                //$pf.expandTree(me.find('tbody tr td:nth-child(' + 1 + (selectable ? 1 : 0) + ') .hitarea').eq(idx).parent());
                                //var hitarea = me.find('tbody tr td:nth-child(' + (jdx + 1) + ') .hitarea');
                                //$pf.expandTree(hitarea.eq(idx).parent());
                                //if (typeof opts.onRowExpand == 'function') {
                                //    //opts.onRowExpand();
                                //    opts.onRowExpand.call(hitarea);
                                //}

                                setFixedColumnWidth();
                                setFixedPosition();
                                //defaultDrawCallback();
                                return;
                            } else if ($(e.target).hasClass('pf-row-select')) {
                                me.find('tbody tr td:nth-child(' + (jdx + 1) + ') .pf-row-select').eq(idx).trigger('click');

                                $pf.stopPropagation(e);
                                return;
                            } else {
                                //me.find('tbody tr td:nth-child(1)').eq(idx).trigger('click');
                                //me.find('tbody tr td:nth-child(' + 1 + (selectable ? 1 : 0) + ')').eq(idx).trigger('click');
                                me.find('tbody tr td:nth-child(' + (jdx+1) + ')').eq(idx).trigger('click');
                            }
                        });
                    }(i,j));

                    tmpTr.attr('level', bodyTrI.attr('level'));
                    tmpTr.attr('expanded', bodyTrI.attr('expanded'));
                }
                tmpTr.appendTo(fixedBody);
            }
            fixedColumnTable.append(fixedHeader);
            fixedColumnTable.append(fixedBody);
            //fixedColumnTable.width(width);
            fixedColumnTable.css('backgroundColor', 'white');
            me.parent().append(fixedColumnTable);

            setOddEvenRowCss(fixedBody);


            //锁表头
            var fixedHeadHeader = me.find('thead').clone(true);
            var fixedHeadBody = $('<tbody></tbody>');


            fixedHeadTable.append(fixedHeadHeader);
            fixedHeadTable.append(fixedHeadBody);
            me.parent().append(fixedHeadTable);

            //锁左上角
            var fixedCornerHeader = fixedHeader.clone(true);
            var fixedCornerBody = $('<tbody></tbody>');

            fixedCornerTable.append(fixedCornerHeader);
            fixedCornerTable.append(fixedCornerBody);
            me.parent().append(fixedCornerTable);
            
            //////fixedColumnTable[0]
            me.parent().unbind('scroll', setFixedPosition).bind('scroll', setFixedPosition);
            setFixedColumnWidth();
            setFixedPosition();//异步tableApi.loadChildNode(),是靠这一句来刷新top的
            
            
        }

        //if (selectable) {
        //    //$headTable = $pfTable.parent().parent().find('.dataTables_scrollHead table');
        //    //if ($headTable.attr('selectAllBinded') !== 'true') {
        //    //    $headTable.on('click', 'thead tr input.pf-row-select-all', function (e) {
        //    //        $headTable.attr('selectAllBinded', 'true');
        //    //        //alert(1);
        //    //        $pf.stopPropagation(e);
        //    //        //debugger;
        //    //        var b = $(this).is(':checked');
        //    //        //if (b === true) {

        //    //        //}
        //    //        var cbs = $pfTable.find('tbody tr input.pf-row-select');
        //    //        cbs.each(function (index, element) {
        //    //            var cb = $(element);
        //    //            if (cb.is(':checked') !== b) { cb.click(); }
        //    //        });

        //    //    });
        //    //}
        //}
    };
    //debugger;
    var drawCallback = null;
    if (typeof opts.drawCallback == 'function') {
        var userDrawCallback = opts.drawCallback;
        drawCallback = function () {
            defaultDrawCallback();
            userDrawCallback();
        }
        delete opts.drawCallback;
    } else {
        drawCallback =defaultDrawCallback;
    }
    var defaultOpts = jQuery.extend({

    }, opts || {});
    var opts = jQuery.extend({}, defaultOpts);
    var result = {};
    function createTr(list, pId, depth) {
        if (depth === undefined) { depth =0;}
        var rowId = 1;
        if (pId !== undefined) { rowId = pId + 1; }
        var result = [];
        for (var i = 0; i < list.length; i++) {
            var row = { id: rowId, pId: pId, data: list[i].Data, depth: depth };
            result.push(row);
            if (list[i].Children) {
                var c = createTr(list[i].Children, rowId,depth+1);
                for (var j = 0; j < c.length; j++) {
                    result.push(c[j]);
                }
                rowId = rowId + c.length;
            }
            rowId++;
        }
        return result;
    }
    function createTd(column, value) {
        var style = '';
        if ((column.dataType === 'decimal' || column.dataType === 'int') && value !== null && value !== undefined) {
            value = $pf.thousandth(value);
            style += 'text-align:right;padding-right: 9px;';
            //style = 'style="text-align:right;padding-right: 9px"';
        }
        if (column.visible === false) { style += 'display:none;'; }
        if (style.length > 0) { style = 'style="'+style+'"';}
        if (value === null) { return '<td ' + style + '></td>';}
        return '<td ' + style + '>' + value + '</td>';
    }
    //function createTrByTreeData(data, columns, tr) {//data为后台返回的TreeStore
    //    if (tr === undefined) {
    //        tr = $('<tr></tr>');
    //    }
    //    //var isFirstFloor = tr === undefined || tr === null;
    //    var isFirstFloor = tr.find('.linearea').length<1;
    //    var level = isFirstFloor ? 0 : tr.attr('level');

    //    var h = '';
    //    var iLevel = null;
    //    if (level !== null && level !== undefined) { iLevel = parseInt(level) + 1; }
    //    else { iLevel = 0;}

    //    for (var i = 0; i < data.length; i++) {
    //        var trData = data[i].Data;
    //        var ij = 0;
    //        h += '<tr class="pfGridItem" level="' + iLevel + '" >';

    //        //debugger;
    //        if (selectable) {
    //            h += "<td><input type=\"checkbox\" class=\"pf-row-select\"></td>";
    //        }
    //        //就根据后台的columns顺序来生成好了,因为打印方法要使用,所以后台反正要写columns的,以后台为准
    //        $pf.eachLeaf({ Children: columns }, function (c) {
    //            var txt = trData[c.data];
    //            if (txt === undefined) { txt = ''; }
    //            if (ij === 0) {
    //                var linearea = '';
    //                for (var k = 0; k < iLevel; k++) {
    //                    //异步也可以划线--benjamin20190712
    //                    var lineClass = '';
    //                    if (!isFirstFloor) {//为了共用createTrByTreeData方法,tr可以传入null
    //                        if (k < iLevel - 1
    //                            ) {//当不是最右边的格
    //                            var pLine = tr.find('.linearea').eq(k);
    //                            if (pLine.hasClass('linearea-ud') || pLine.hasClass('linearea-urd')) {
    //                                lineClass = 'linearea-ud';
    //                            } 
    //                        } else {
    //                            if (i < data.length - 1) {//当不是最后一行
    //                                lineClass = 'linearea-urd';
    //                            } else {
    //                                lineClass = 'linearea-ur';
    //                            }
    //                        }

    //                        linearea += '<div class="linearea '+lineClass+'"></div>';
    //                    }
    //                }
    //                h += '<td>' + linearea + '<div class="hitarea hitarea-closed"></div>' + txt + '</td>';
    //            } else {
    //                h += createTd(c, txt);
    //            }
    //            ij++;
    //        });

    //        h += '</tr>';
    //    }
    //    if (data.Children.length > 0) {
    //        tr
    //        h += createTrByTreeData(data.Children, columns)
    //    }
    //    if (h !== '') { $(tr).after(h); }
    //    //return h;
    //    return tr;
    //}
    result.loadData = function (data, loadOpts) {//当json的深度和行数非常大时,不能通过post来实现,只能用iframe放入子页面的方法
        loadOpts = loadOpts || {};
        //debugger;
        //if (data !== null && data !== undefined && typeof data === 'string') {//很复杂的JSON时,后端手动序列化为str后返回
        //    data = JSON.parse(data);
        //}
        var $body = me.find('tbody');
        if ($body.length === 0) { me.append('<tbody></tbody>'); $body = me.find('tbody'); }
        $body.html('');
        var $head = me.find('thead');
        if ($head.length === 0) { me.prepend('<thead></thead>'); $head = me.find('thead'); }
        $head.html('');
        if (data && data.Result !== false) {
            if (data.data) {
                var h = '';
                //h += createTrByTreeData(data);
                var trs = createTr(data.data);
                var treeMatrix = new TreeMatrix();
                treeMatrix.initByTreeList(data.data);
                //console.info(treeMatrix.getNetLine(0, 1));
                
                for (var i = 0; i < trs.length; i++) {
                    var tr = trs[i];

                    ////h += '<tr class="treegrid-' + tr.id + ' '
                    ////    + (tr.pId == null ? '' : ('treegrid-parent-' + tr.pId))
                    ////    + '">';//jquery treegrid的写法

                    //h += '<tr class="treegrid-' +tr.id + ' '
                    //    +(tr.pId == null ? '': ('treegrid-parent-' +tr.pId))
                    //    + ' pfGridItem" level="' +iLevel + '">';
                    ////h += '<tr class="pfGridItem" level="' +iLevel + '" >';

                    var iLevel = tr.depth;
                    h += $pf.formatString("<tr class='pfGridItem {0}' level='{1}' {2} {3}>",
                        '',//_itemClass,
                        iLevel,
                        closeTree?"": "expanded='expanded'",
                        closeTree && iLevel > 0 ? "style='display:none'" : ""
                    );

                    //debugger;
                    //if (selectable) {//测试后可启用
                    //    h += "<td><input type=\"checkbox\" class=\"pf-row-select\"></td>";
                    //}

                    if (data.columns) {
                        for (var j = 0; j < data.columns.length; j++) {
                            var value = tr.data[data.columns[j].data];
                            
                            if (j === 0) {
                                //var iLevel = tr.depth;
                                var css = closeTree? "hitarea hitarea-closed" : "hitarea hitarea-expanded";
                                var linearea = '';
                                //debugger;
                                    for (var k = 0; k < iLevel; k++) {
                                        //异步也可以划线--benjamin20190712
                                        var lineClass = '';
                                        //if (k < iLevel - 1) {//当不是最右边的格
                                        //    var pLine = tr.find('.linearea').eq(k);
                                        //    if (pLine.hasClass('linearea-ud') || pLine.hasClass('linearea-urd')) {
                                        //        lineClass = 'linearea-ud';
                                        //    } 
                                        //} else {
                                        //    if (i < data.data.length - 1) {//当不是最后一行
                                        //        lineClass = 'linearea-urd';
                                        //    } else {
                                        //        lineClass = 'linearea-ur';
                                        //    }
                                        //}
                                        switch (treeMatrix.getNetLine(j,i)) {
                                            case '┝':
                                                lineClass='linearea-urd';
                                                break;
                                            case '│':
                                                lineClass = 'linearea-ud';
                                                break;
                                            case '┕':
                                                lineClass = 'linearea-ur';
                                                break;
                                            default:
                                                break;
                                        }
                                        //line += string.Format("<div class='{0} {1}'></div>", "linearea ", GetClassByTreeMatrixNetLine(matrix.GetNetLine(j, rowIdx)));
                                        linearea += '<div class="linearea '+lineClass + '"></div>';
                                    }
                                    h += '<td>' + linearea + '<div class="'+css+'"></div>' + value + '</td>';
                            } else {
                                h += createTd(data.columns[j], value);
                            }

                            //var style = '';
                            //if ((data.columns[j].dataType === 'decimal' || data.columns[j].dataType === 'int') && value !== null && value !== undefined) {
                            //    value = $pf.thousandth(value);
                            //    style = 'style="text-align:right;padding-right: 9px"';
                            //}
                            //h += '<td ' + style + '>' + value + '</td>';
                        }
                    } else {
                        for (var j in tr.data) {
                            if (tr.data.hasOwnProperty(j)) {
                                h += '<td>' + tr.data[j] + '</td>';
                            }
                        }
                    }
                    h += '</tr>';
                }
                $body.append(h);
            }
            if (data.columns) {
                var h = '<tr>';
                for (var j = 0; j < data.columns.length; j++) {
                    h += '<th>' + (data.columns[j].title || data.columns[j].data) + '</th>';
                }
                h += '</tr>';
                $head.append(h);
            }
            if (typeof loadOpts.success == 'function') {
                loadOpts.success(data);
            }
        } else {
            $head.append('<tr><th>提示</th></tr>');
            var message = "没有数据";
            if (data && data.Message) { message = data.Message; }
            $body.append('<tr><td>' + message + '</td></tr>');
        }

        //me.treegrid(opts);//使用了jquery的树型类

        setOddEvenRowCss($body);

        if (typeof loadOpts.complete == 'function') {
            loadOpts.complete(data);
        }
    };
    result.loadUrl = function (url, loadOpts) {
        loadOpts = loadOpts || {};
        $.post(url, null, function (data) {
            result.loadData(data, loadOpts);
            _url = url;
        });
    };
    var layerIdx = null;
    result.loadChildNode = function (td, url, loadOpts) {//单层加载(pfGrid).为便于使用,td可以传tr
        //debugger;
        //if (td.find) {
        //} else {
        //    td = $(td);
        //}
        td = $pf.getJQ(td);

        if (td[0].nodeName === 'TR') {
            //debugger;
            td = td.find('td .hitarea').parent();
        }
        //var td = $(td);
        var tr = td.parent('tr');
        var level = tr.attr('level');
        var expanded = tr.attr('expanded');
        var loaded = tr.attr('loaded');
        //var me = this;
        loadOpts = loadOpts || {};
        //debugger;
        //$pf.expandTree(td);
        if (//expanded !== 'expanded' &&
            loaded !== 'loaded') {//pfUtils.js里展开了
            //debugger;
            layerIdx = layer.load('正在查询请稍候');
            $.post(url, null, function (data) {
                if (data && data.Result !== false) {
                    if (data.data) {
                        //var h = createTrByTreeData(data,tr);
                        //这部分代码暂不要共用了,因为只是单层的
                        var h = '';
                        var iLevel = null;
                        if (level !== null && level !== undefined) { iLevel = parseInt(level) + 1; }

                        for (var i = 0; i < data.data.length; i++) {
                            var trData = data.data[i].Data;
                            var ij = 0;
                            h += '<tr class="pfGridItem" level="' + iLevel + '" >';

                            //debugger;
                            if (selectable) {
                                h += "<td><input type=\"checkbox\" class=\"pf-row-select\"></td>";
                            }
                            //就根据后台的columns顺序来生成好了,因为打印方法要使用,所以后台反正要写columns的,以后台为准
                            $pf.eachLeaf({ Children: data.columns }, function (c) {
                                var txt = trData[c.data];
                                if (txt === undefined) { txt = ''; }
                                if (ij === 0) {
                                    var linearea = '';
                                    for (var k = 0; k < iLevel; k++) {
                                        //异步也可以划线--benjamin20190712
                                        var lineClass = '';
                                        if (k < iLevel - 1) {//当不是最右边的格
                                            var pLine = tr.find('.linearea').eq(k);
                                            if (pLine.hasClass('linearea-ud') || pLine.hasClass('linearea-urd')) {
                                                lineClass = 'linearea-ud';
                                            } 
                                        } else {
                                            if (i < data.data.length - 1) {//当不是最后一行
                                                lineClass = 'linearea-urd';
                                            } else {
                                                lineClass = 'linearea-ur';
                                            }
                                        }

                                        linearea += '<div class="linearea '+lineClass+'"></div>';
                                    }
                                    h += '<td>' + linearea + '<div class="hitarea hitarea-closed"></div>' + txt + '</td>';
                                } else {
                                    h += createTd(c, txt);
                                }
                                ij++;
                            });

                            h += '</tr>';
                        }
                        if (h !== '') { $(tr).after(h); }

                        //$pf.expandTree(td);
                        //var hitarea = td.find('.hitarea');
                        //tr.attr('expanded', 'expanded');
                        //hitarea.removeClass('hitarea-closed');
                        //hitarea.addClass('hitarea-expanded');
                        drawCallback();
                    }
                }
                tr.attr('loaded', 'loaded');
                if (layerIdx) { layer.close(layerIdx); }
                //debugger;
                setOddEvenRowCss(me.find('tbody'));
                //me.find('tbody').find("tr:odd").css("backgroundColor", "#eff6fa");//奇偶行样式
                //me.find('tbody').find("tr:even").css("backgroundColor", "white");
                if (typeof loadOpts.complete == 'function') {
                    loadOpts.complete(data);
                }
                //result.loadData(data, loadOpts);
                //_url = url;
            });
        }
        //else {
        //    setFixedColumnWidth();
        //    //$pf.expandTree(td);
        //}
    };
    result.setUrl = function (url) {
        _url = url;

    };
    //result.initTable = function () {//用页面上已生成tr节点的完整Table来初始化
    //    $(selector).treegrid(opts);
    //    //$(selector + ' tbody tr td:nth-child(1)').click(function (e) { $pf.expandTree(this); });//展开事件
    //    $(selector).on('click', 'tbody tr td:nth-child(1)', function (e) {//注意索引是从1开始的
    //        $pf.expandTree(this);
    //    });
    //};
    result.exportExcel = function (event) {
        //alert(1);
        //debugger;
        var url = _url;
        if (url[0] !== '/') {//如果是相对地址,要转为绝对地址
            url = window.location.pathname.replace(/[^/]*$/, url)
        }
        //debugger;
        $pf.exporter({
            title: null,
            dataAction: url
        })
        .download($(event.currentTarget).attr("suffix"))
        ;
    };
    //工具栏
    //debugger;
    var buttons = [];
    var excelBtn={
        text: '导出Excel', action: result.exportExcel
    };
    if (opts.buttons instanceof Array) {
        for (var i = 0; i < opts.buttons.length; i++) {
            switch (opts.buttons[i].Name) {
                case 'Export':
                case 'excel':
                    buttons.push(excelBtn);
                    break;
                default:
                    //buttons.push({ text: opts.buttons[i].Text });
                    (function (name, text, alwayShow) {//注意action会有作用域的问题
                        buttons.push({
                            text: text,
                            alwayShow: alwayShow,
                            action: function (event) {
                                //debugger;
                                var data = [];
                                var rows = result.getSelectedRows();
                                if (rows.length > 0) {
                                    for (var i = 0; i < rows.length; i++) {
                                        data.push(result.tableApi.row(rows[i]).data());
                                    }
                                }
                                //var data = result.tableApi.row('.selected').data();
                                $pfTable.trigger('tbar.' + name, [data]);
                            }
                        });
                    }(opts.buttons[i].Name, opts.buttons[i].Text, opts.buttons[i].AlwayShow));
                    break;
            }
            //if (typeof opts.buttons[i] === 'string') {//字符串型(系统按钮)
            //    switch (opts.buttons[i]) {
            //        case 'Export':
            //        case 'excel':
            //            buttons.push(excelBtn);
            //            break;
            //        default:
            //            //buttons.push(opts.buttons[i]);
            //            break;
            //    }
            //} else {
            //    buttons.push(opts.buttons[i]);//对象型(自定义按钮)
            //}
        }
    } else {
        //buttons = [excelBtn];
        buttons = [];
    }
    if(buttons.length>0){
        var $operate = $('<div class="table-operate ue-clear"></div>');// style="display:none;"
        //var buttons = $pf.getTableToolbar(opts);
        for (var i = 0; i < buttons.length; i++) {
            var button = $('<a href="javascript:;" class="' + (buttons[i].icon || 'add') + '" id="' + me.id + '-exportExcel">' + buttons[i].text + '</a>');
            button.on('click', buttons[i].action);
            button.appendTo($operate);
        }
        //me.before($operate);
        me.parent().before($operate);//放在table-box外面才不会影响锁定列(原版也是放在box外)--ben20190627
    }
    drawCallback();

    result.tableApi = {
        row: function (rowDom) {
            return {
                data: function () {
                    //var cols = 
                    //var colIdxs = $pf.getTableColumnIdxs(selector);
                    //var colIdxs = $pf.getTableColumnIdxs(selector);

                    //me.find('thead tr td').each(function (i, ele) {
                    //    var td = $(ele);
                    //    var t = td.attr('field-name') || td.text();
                    //    cols.push(t);
                    //});
                    var row=$(rowDom);
                    var r = {};
                    for (var i = 0; i < _colIdxs.length; i++) {
                        r[_colIdxs[i]] = row.children()[i].innerText;
                    }
                    return r;
                }
            }
        }
    }
    result.isRowSelectAll = function () {
        //return $headTable.find('thead tr input.pf-row-select-all').is(':checked');
        return $pfTable.find('thead tr input.pf-row-select-all').is(':checked');
    };
    result.getSelectedRows = function () {
        return $pfTable.find('tbody tr.selected');
    };

    me.on('click', 'tbody tr td:nth-child(' + (selectable ? 2 : 1) + ') .hitarea', function (e) {//注意索引是从1开始的
        //alert(1);
        $pf.stopPropagation(e);
        var hitarea = $(this);
        var td = hitarea.parent();
        $pf.expandTree(td);

        if (typeof opts.onRowExpand == 'function') {
            var tr = td.parent('tr');
            //var rowData = result.tableApi.row(tr).data();
            ////var rowData = {};
            ////for (var i = 0; i < _colIdxs.length; i++) {
            ////    rowData[_colIdxs[i]] = tr.find('td:nth-child(' + (i + 1) + ')').text();
            ////}
            //////opts.onRowExpand();
            opts.onRowExpand.call(hitarea, tr);
        }
        //defaultDrawCallback();
        resetFixedColumnSize();//重设宽度也不够,要重设高度
    });
    if (selectable) {
        result.selectRow = function (tr) {
            if (tr.hasClass('selected')) {
                tr.removeClass('selected');
                tr.find('input.pf-row-select').prop("checked", false);
            }
            else {
                if (selectMode == 1) {
                    var trs = result.tableApi.$('tr.selected');
                    var cbs = trs.find('input.pf-row-select');
                    cbs.prop("checked", false);
                    trs.removeClass('selected');
                }
                tr.addClass('selected');
                tr.find('input.pf-row-select').prop("checked", true);
            }
        };
        $pfTable.on('click', 'thead tr input.pf-row-select-all', function (e) {
            $pf.stopPropagation(e);
            var b = $(this).is(':checked');

            var cbs = $pfTable.find('tbody tr input.pf-row-select');
            cbs.each(function (index, element) {
                var cb = $(element);
                if (cb.is(':checked') !== b) {
                    cb.click();
                    //cb.trigger('click');
                }
            });

        });
        //顺序:
        //1.全选->行checkbox点击->result.selectRow()
        //2.tr点击->行checkbox点击->result.selectRow()
        $pfTable.on('click', 'tbody tr input.pf-row-select', function (e) {
            $pf.stopPropagation(e);
            var tr = $(this).parent().parent();

            //这段是参照pfTable的,但忘记当时为什么这样写了
            //var tempTb = tr.parent().parent();
            //if (tempTb.attr('id') !== $pfTable.attr('id')) {//如果有锁定列时,点击锁定列时进入这里
            //    var idx = tr.parent().find('tr').index(tr);//行序号
            //    $pfTable.find('tbody tr:nth-child(' + (idx + 1) + ')').click();
            //    return;
            //}

            if (opts.fixedColumns !== undefined && opts.fixedColumns !== false) {//如果有锁定列时,点击普通列进入这里
                var idx = tr.parent().find('tr').index(tr);//行序号
                result.selectRow($('#' + me[0].id + '-fixedColumn tbody tr:nth-child(' + (idx + 1) + ') '));
            }

            result.selectRow(tr);
        });
        $pfTable.on('click', 'tbody tr', function (e) {
            $pf.stopPropagation(e);
            $(this).find('input.pf-row-select').click();

        });

    }
    return result;
};

/*
*统计图表(需要引用jqwidgets)
*/
jQuery.fn.pfPivotTable = function (opts) {
    var $pfTable = this;
    $pfTable.css('width', '800px');
    $pfTable.css('height', '400px');
    $pfTable.css('backgroundColor', 'white');

    var defaultOpts = jQuery.extend({
        //theme: 'classic',
        //source: pivotAdapter,
        treeStyleRows: true,
        autoResize: false,
        multipleSelectionEnabled: true
    }, opts || {});

    function newOpts() {
        var r = jQuery.extend({}, defaultOpts);
        //if (r.order instanceof Array) {
        //    r.order = r.order.slice(0);//数组型的成员要这样才不会因opts改变而改变
        //}
        return r;
    }
    opts = newOpts();

    var _url = '';
    var result = {};

    var $errorTableContainer = $('<div class="table"><div class="table-box"><table></table></div></div>')
    //var $errorTable = $('<table></table>');
    var $errorTable = $errorTableContainer.find('table');
    $pfTable.after($errorTableContainer);
    result.loadUrl = function (url, loadOpts) {
        loadOpts = loadOpts || {};
        var layerIdx = layer.load('正在查询请稍候');
        $.post(url, null, function (data) {
            if (data && data.Result !== false) {
                $errorTable.hide();
                $pfTable.show();
                _url = url;

                //var data = new Array();

                //var firstNames =
                //[
                //    "Andrew", "Nancy", "Shelley", "Regina", "Yoshi", "Antoni", "Mayumi", "Ian", "Peter", "Lars", "Petra", "Martin", "Sven", "Elio", "Beate", "Cheryl", "Michael", "Guylene"
                //];

                //var lastNames =
                //[
                //    "Fuller", "Davolio", "Burke", "Murphy", "Nagase", "Saavedra", "Ohno", "Devling", "Wilson", "Peterson", "Winkler", "Bein", "Petersen", "Rossi", "Vileid", "Saylor", "Bjorn", "Nodier"
                //];

                //var productNames =
                //[
                //    "Black Tea", "Green Tea", "Caffe Espresso"
                //];

                //var priceValues =
                //[
                //    "2.25", "1.5", "3.0", "3.3", "4.5", "3.6", "3.8", "2.5", "5.0", "1.75", "3.25", "4.0"
                //];

                //for (var i = 0; i < 500; i++) {
                //    var row = {};
                //    var productindex = Math.floor(Math.random() * productNames.length);
                //    var price = parseFloat(priceValues[productindex]);
                //    var quantity = 1 + Math.round(Math.random() * 10);

                //    row["firstname"] = firstNames[Math.floor(Math.random() * firstNames.length)];
                //    row["lastname"] = lastNames[Math.floor(Math.random() * lastNames.length)];
                //    row["productname"] = productNames[productindex];
                //    row["price"] = price;
                //    row["quantity"] = quantity;
                //    row["total"] = price * quantity;

                //    data[i] = row;
                //}

                var datafields = [];
                for (var i = 0; i < data.columns.length; i++) {
                    datafields.push({
                        name:data.columns[i].data,
                        type:data.columns[i].dataType
                    });
                }

                // create a data source and data adapter
                var source =
                {
                    //localdata: data,
                    localdata: data.data,
                    datatype: "array",
                    datafields: datafields
                    //[
                    //    { name: 'firstname', type: 'string' },
                    //    { name: 'lastname', type: 'string' },
                    //    { name: 'productname', type: 'string' },
                    //    { name: 'quantity', type: 'number' },
                    //    { name: 'price', type: 'number' },
                    //    { name: 'total', type: 'number' }
                    //]
                };

                var dataAdapter = new $.jqx.dataAdapter(source);
                dataAdapter.dataBind();

                opts = newOpts();
                // create a pivot adapter from the dataAdapter
                var pivotAdapter = new $.jqx.pivot(
                    dataAdapter,
                    {
                        pivotValuesOnRows: false,
                        totals: { rows: { subtotals: true, grandtotals: true }, columns: { subtotals: false, grandtotals: true } },
                        //rows: [{ dataField: 'firstname' }, { dataField: 'lastname' }],
                        //columns: [{ dataField: 'productname' }],
                        //values: [
                        //    { dataField: 'price', 'function': 'sum', text: 'sum', width: NamedNodeMap, formatSettings: { prefix: '$', decimalPlaces: 2 } },
                        //    { dataField: 'price', 'function': 'count', text: 'count' },
                        //    { dataField: 'price', 'function': 'average', text: 'average', formatSettings: { prefix: '$', decimalPlaces: 2 } }
                        //]

                        //rows: [{ dataField: '店主姓名' }, { dataField: '年龄段' }],//YJLevel功能的配置
                        //columns: [{ dataField: '当月级别' }],
                        //values: [
                        //    {
                        //        dataField: '人数', 'function': 'sum', text: '人数', width: NamedNodeMap
                        //        //, formatSettings: { prefix: '$', decimalPlaces: 0 } 
                        //    },
                        //]
                        rows:opts.rows,
                        columns: opts.columns,
                        values: opts.values
                    });
                delete opts.rows;
                delete opts.columns;
                delete opts.values;
                opts.source = pivotAdapter;
                if (typeof getJqxPivotLocalization == 'function') {
                    opts.localization = getJqxPivotLocalization('chs');
                }

                $pfTable.jqxPivotGrid(opts
                    //{
                    //    theme: 'classic',
                    //    source: pivotAdapter,
                    //    treeStyleRows: true,
                    //    autoResize: false,
                    //    multipleSelectionEnabled: true
                    //}
                    );
            } else {                
                var message = "没有数据";
                if (data && data.Message) { message = data.Message; }
                //$pf.warningPopups(message);
                $errorTable.html('<thead><tr><th style="border:1px solid #c1d3de;background-color:#E8F1F7;">提示</th></tr></thead><tbody><tr onclick="$pf.stopPropagation(arguments[0])"><td  onclick="$pf.stopPropagation(arguments[0])"  style="border:1px solid rgb(17, 17, 17);vertical-align:top;height:auto;">' + message + '</td></tr></tbody>');
                $pfTable.hide();
                $errorTable.show();
            }
            if (layerIdx) { layer.close(layerIdx); }
        });
    };
    return result;
};
+function ($) {
  'use strict';

  // TOOLTIP PUBLIC CLASS DEFINITION
  // ===============================

  var Tooltip = function (element, options) {
    this.type       =
    this.options    =
    this.enabled    =
    this.timeout    =
    this.hoverState =
    this.$element   = null

    this.init('tooltip', element, options)
  }

  Tooltip.VERSION  = '3.3.1'

  Tooltip.TRANSITION_DURATION = 150

  Tooltip.DEFAULTS = {
    animation: true,
    placement: 'top',
    selector: false,
    template: '<div class="tooltip" role="tooltip"><div class="tooltip-arrow"></div><div class="tooltip-inner"></div></div>',
    trigger: 'hover focus',
    title: '',
    delay: 0,
    html: false,
    container: false,
    viewport: {
      selector: 'body',
      padding: 0
    }
  }

  Tooltip.prototype.init = function (type, element, options) {
    this.enabled   = true
    this.type      = type
    this.$element  = $(element)
    this.options   = this.getOptions(options)
    this.$viewport = this.options.viewport && $(this.options.viewport.selector || this.options.viewport)

    var triggers = this.options.trigger.split(' ')

    for (var i = triggers.length; i--;) {
      var trigger = triggers[i]

      if (trigger == 'click') {
        this.$element.on('click.' + this.type, this.options.selector, $.proxy(this.toggle, this))
      } else if (trigger != 'manual') {
        var eventIn  = trigger == 'hover' ? 'mouseenter' : 'focusin'
        var eventOut = trigger == 'hover' ? 'mouseleave' : 'focusout'

        this.$element.on(eventIn  + '.' + this.type, this.options.selector, $.proxy(this.enter, this))
        this.$element.on(eventOut + '.' + this.type, this.options.selector, $.proxy(this.leave, this))
      }
    }

    this.options.selector ?
      (this._options = $.extend({}, this.options, { trigger: 'manual', selector: '' })) :
      this.fixTitle()
  }

  Tooltip.prototype.getDefaults = function () {
    return Tooltip.DEFAULTS
  }

  Tooltip.prototype.getOptions = function (options) {
    options = $.extend({}, this.getDefaults(), this.$element.data(), options)

    if (options.delay && typeof options.delay == 'number') {
      options.delay = {
        show: options.delay,
        hide: options.delay
      }
    }

    return options
  }

  Tooltip.prototype.getDelegateOptions = function () {
    var options  = {}
    var defaults = this.getDefaults()

    this._options && $.each(this._options, function (key, value) {
      if (defaults[key] != value) options[key] = value
    })

    return options
  }

  Tooltip.prototype.enter = function (obj) {
    var self = obj instanceof this.constructor ?
      obj : $(obj.currentTarget).data('bs.' + this.type)

    if (self && self.$tip && self.$tip.is(':visible')) {
      self.hoverState = 'in'
      return
    }

    if (!self) {
      self = new this.constructor(obj.currentTarget, this.getDelegateOptions())
      $(obj.currentTarget).data('bs.' + this.type, self)
    }

    clearTimeout(self.timeout)

    self.hoverState = 'in'

    if (!self.options.delay || !self.options.delay.show) return self.show()

    self.timeout = setTimeout(function () {
      if (self.hoverState == 'in') self.show()
    }, self.options.delay.show)
  }

  Tooltip.prototype.leave = function (obj) {
    var self = obj instanceof this.constructor ?
      obj : $(obj.currentTarget).data('bs.' + this.type)

    if (!self) {
      self = new this.constructor(obj.currentTarget, this.getDelegateOptions())
      $(obj.currentTarget).data('bs.' + this.type, self)
    }

    clearTimeout(self.timeout)

    self.hoverState = 'out'

    if (!self.options.delay || !self.options.delay.hide) return self.hide()

    self.timeout = setTimeout(function () {
      if (self.hoverState == 'out') self.hide()
    }, self.options.delay.hide)
  }

  Tooltip.prototype.show = function () {
    var e = $.Event('show.bs.' + this.type)

    if (this.hasContent() && this.enabled) {
      this.$element.trigger(e)

      var inDom = $.contains(this.$element[0].ownerDocument.documentElement, this.$element[0])
      if (e.isDefaultPrevented() || !inDom) return
      var that = this

      var $tip = this.tip()

      var tipId = this.getUID(this.type)

      this.setContent()
      $tip.attr('id', tipId)
      this.$element.attr('aria-describedby', tipId)

      if (this.options.animation) $tip.addClass('fade')

      var placement = typeof this.options.placement == 'function' ?
        this.options.placement.call(this, $tip[0], this.$element[0]) :
        this.options.placement

      var autoToken = /\s?auto?\s?/i
      var autoPlace = autoToken.test(placement)
      if (autoPlace) placement = placement.replace(autoToken, '') || 'top'

      $tip
        .detach()
        .css({ top: 0, left: 0, display: 'block' })
        .addClass(placement)
        .data('bs.' + this.type, this)

      this.options.container ? $tip.appendTo(this.options.container) : $tip.insertAfter(this.$element)

      var pos          = this.getPosition()
      var actualWidth  = $tip[0].offsetWidth
      var actualHeight = $tip[0].offsetHeight

      if (autoPlace) {
        var orgPlacement = placement
        var $container   = this.options.container ? $(this.options.container) : this.$element.parent()
        var containerDim = this.getPosition($container)

        placement = placement == 'bottom' && pos.bottom + actualHeight > containerDim.bottom ? 'top'    :
                    placement == 'top'    && pos.top    - actualHeight < containerDim.top    ? 'bottom' :
                    placement == 'right'  && pos.right  + actualWidth  > containerDim.width  ? 'left'   :
                    placement == 'left'   && pos.left   - actualWidth  < containerDim.left   ? 'right'  :
                    placement

        $tip
          .removeClass(orgPlacement)
          .addClass(placement)
      }

      var calculatedOffset = this.getCalculatedOffset(placement, pos, actualWidth, actualHeight)

      this.applyPlacement(calculatedOffset, placement)

      var complete = function () {
        var prevHoverState = that.hoverState
        that.$element.trigger('shown.bs.' + that.type)
        that.hoverState = null

        if (prevHoverState == 'out') that.leave(that)
      }

      $.support.transition && this.$tip.hasClass('fade') ?
        $tip
          .one('bsTransitionEnd', complete)
          .emulateTransitionEnd(Tooltip.TRANSITION_DURATION) :
        complete()
    }
  }

  Tooltip.prototype.applyPlacement = function (offset, placement) {
    var $tip   = this.tip()
    var width  = $tip[0].offsetWidth
    var height = $tip[0].offsetHeight

    // manually read margins because getBoundingClientRect includes difference
    var marginTop = parseInt($tip.css('margin-top'), 10)
    var marginLeft = parseInt($tip.css('margin-left'), 10)

    // we must check for NaN for ie 8/9
    if (isNaN(marginTop))  marginTop  = 0
    if (isNaN(marginLeft)) marginLeft = 0

    offset.top  = offset.top  + marginTop
    offset.left = offset.left + marginLeft

    // $.fn.offset doesn't round pixel values
    // so we use setOffset directly with our own function B-0
    $.offset.setOffset($tip[0], $.extend({
      using: function (props) {
        $tip.css({
          top: Math.round(props.top),
          left: Math.round(props.left)
        })
      }
    }, offset), 0)

    $tip.addClass('in')

    // check to see if placing tip in new offset caused the tip to resize itself
    var actualWidth  = $tip[0].offsetWidth
    var actualHeight = $tip[0].offsetHeight

    if (placement == 'top' && actualHeight != height) {
      offset.top = offset.top + height - actualHeight
    }

    var delta = this.getViewportAdjustedDelta(placement, offset, actualWidth, actualHeight)

    if (delta.left) offset.left += delta.left
    else offset.top += delta.top

    var isVertical          = /top|bottom/.test(placement)
    var arrowDelta          = isVertical ? delta.left * 2 - width + actualWidth : delta.top * 2 - height + actualHeight
    var arrowOffsetPosition = isVertical ? 'offsetWidth' : 'offsetHeight'

    $tip.offset(offset)
    this.replaceArrow(arrowDelta, $tip[0][arrowOffsetPosition], isVertical)
  }

  Tooltip.prototype.replaceArrow = function (delta, dimension, isHorizontal) {
    this.arrow()
      .css(isHorizontal ? 'left' : 'top', 50 * (1 - delta / dimension) + '%')
      .css(isHorizontal ? 'top' : 'left', '')
  }

  Tooltip.prototype.setContent = function () {
    var $tip  = this.tip()
    var title = this.getTitle()

    $tip.find('.tooltip-inner')[this.options.html ? 'html' : 'text'](title)
    $tip.removeClass('fade in top bottom left right')
  }

  Tooltip.prototype.hide = function (callback) {
    var that = this
    var $tip = this.tip()
    var e    = $.Event('hide.bs.' + this.type)

    function complete() {
      if (that.hoverState != 'in') $tip.detach()
      that.$element
        .removeAttr('aria-describedby')
        .trigger('hidden.bs.' + that.type)
      callback && callback()
    }

    this.$element.trigger(e)

    if (e.isDefaultPrevented()) return

    $tip.removeClass('in')

    $.support.transition && this.$tip.hasClass('fade') ?
      $tip
        .one('bsTransitionEnd', complete)
        .emulateTransitionEnd(Tooltip.TRANSITION_DURATION) :
      complete()

    this.hoverState = null

    return this
  }

  Tooltip.prototype.fixTitle = function () {
    var $e = this.$element
    if ($e.attr('title') || typeof ($e.attr('data-original-title')) != 'string') {
      $e.attr('data-original-title', $e.attr('title') || '').attr('title', '')
    }
  }

  Tooltip.prototype.hasContent = function () {
    return this.getTitle()
  }

  Tooltip.prototype.getPosition = function ($element) {
    $element   = $element || this.$element

    var el     = $element[0]
    var isBody = el.tagName == 'BODY'

    var elRect    = el.getBoundingClientRect()
    if (elRect.width == null) {
      // width and height are missing in IE8, so compute them manually; see https://github.com/twbs/bootstrap/issues/14093
      elRect = $.extend({}, elRect, { width: elRect.right - elRect.left, height: elRect.bottom - elRect.top })
    }
    var elOffset  = isBody ? { top: 0, left: 0 } : $element.offset()
    var scroll    = { scroll: isBody ? document.documentElement.scrollTop || document.body.scrollTop : $element.scrollTop() }
    var outerDims = isBody ? { width: $(window).width(), height: $(window).height() } : null

    return $.extend({}, elRect, scroll, outerDims, elOffset)
  }

  Tooltip.prototype.getCalculatedOffset = function (placement, pos, actualWidth, actualHeight) {
    return placement == 'bottom' ? { top: pos.top + pos.height,   left: pos.left + pos.width / 2 - actualWidth / 2  } :
           placement == 'top'    ? { top: pos.top - actualHeight, left: pos.left + pos.width / 2 - actualWidth / 2  } :
           placement == 'left'   ? { top: pos.top + pos.height / 2 - actualHeight / 2, left: pos.left - actualWidth } :
        /* placement == 'right' */ { top: pos.top + pos.height / 2 - actualHeight / 2, left: pos.left + pos.width   }

  }

  Tooltip.prototype.getViewportAdjustedDelta = function (placement, pos, actualWidth, actualHeight) {
    var delta = { top: 0, left: 0 }
    if (!this.$viewport) return delta

    var viewportPadding = this.options.viewport && this.options.viewport.padding || 0
    var viewportDimensions = this.getPosition(this.$viewport)

    if (/right|left/.test(placement)) {
      var topEdgeOffset    = pos.top - viewportPadding - viewportDimensions.scroll
      var bottomEdgeOffset = pos.top + viewportPadding - viewportDimensions.scroll + actualHeight
      if (topEdgeOffset < viewportDimensions.top) { // top overflow
        delta.top = viewportDimensions.top - topEdgeOffset
      } else if (bottomEdgeOffset > viewportDimensions.top + viewportDimensions.height) { // bottom overflow
        delta.top = viewportDimensions.top + viewportDimensions.height - bottomEdgeOffset
      }
    } else {
      var leftEdgeOffset  = pos.left - viewportPadding
      var rightEdgeOffset = pos.left + viewportPadding + actualWidth
      if (leftEdgeOffset < viewportDimensions.left) { // left overflow
        delta.left = viewportDimensions.left - leftEdgeOffset
      } else if (rightEdgeOffset > viewportDimensions.width) { // right overflow
        delta.left = viewportDimensions.left + viewportDimensions.width - rightEdgeOffset
      }
    }

    return delta
  }

  Tooltip.prototype.getTitle = function () {
    var title
    var $e = this.$element
    var o  = this.options

    title = $e.attr('data-original-title')
      || (typeof o.title == 'function' ? o.title.call($e[0]) :  o.title)

    return title
  }

  Tooltip.prototype.getUID = function (prefix) {
    do prefix += ~~(Math.random() * 1000000)
    while (document.getElementById(prefix))
    return prefix
  }

  Tooltip.prototype.tip = function () {
    return (this.$tip = this.$tip || $(this.options.template))
  }

  Tooltip.prototype.arrow = function () {
    return (this.$arrow = this.$arrow || this.tip().find('.tooltip-arrow'))
  }

  Tooltip.prototype.enable = function () {
    this.enabled = true
  }

  Tooltip.prototype.disable = function () {
    this.enabled = false
  }

  Tooltip.prototype.toggleEnabled = function () {
    this.enabled = !this.enabled
  }

  Tooltip.prototype.toggle = function (e) {
    var self = this
    if (e) {
      self = $(e.currentTarget).data('bs.' + this.type)
      if (!self) {
        self = new this.constructor(e.currentTarget, this.getDelegateOptions())
        $(e.currentTarget).data('bs.' + this.type, self)
      }
    }

    self.tip().hasClass('in') ? self.leave(self) : self.enter(self)
  }

  Tooltip.prototype.destroy = function () {
    var that = this
    clearTimeout(this.timeout)
    this.hide(function () {
      that.$element.off('.' + that.type).removeData('bs.' + that.type)
    })
  }


  // TOOLTIP PLUGIN DEFINITION
  // =========================

  function Plugin(option) {
    return this.each(function () {
      var $this    = $(this)
      var data     = $this.data('bs.tooltip')
      var options  = typeof option == 'object' && option
      var selector = options && options.selector

      if (!data && option == 'destroy') return
      if (selector) {
        if (!data) $this.data('bs.tooltip', (data = {}))
        if (!data[selector]) data[selector] = new Tooltip(this, options)
      } else {
        if (!data) $this.data('bs.tooltip', (data = new Tooltip(this, options)))
      }
      if (typeof option == 'string') data[option]()
    })
  }

  var old = $.fn.tooltip

  $.fn.tooltip             = Plugin
  $.fn.tooltip.Constructor = Tooltip


  // TOOLTIP NO CONFLICT
  // ===================

  $.fn.tooltip.noConflict = function () {
    $.fn.tooltip = old
    return this
  }

}(jQuery);
+function ($) {
  'use strict';

  // POPOVER PUBLIC CLASS DEFINITION
  // ===============================

  var Popover = function (element, options) {
    this.init('popover', element, options)
  }

  if (!$.fn.tooltip) throw new Error('Popover requires tooltip.js')

  Popover.VERSION  = '3.3.1'

  Popover.DEFAULTS = $.extend({}, $.fn.tooltip.Constructor.DEFAULTS, {
    placement: 'right',
    trigger: 'click',
    content: '',
    template: '<div class="popover" role="tooltip"><div class="arrow"></div><h3 class="popover-title"></h3><div class="popover-content"></div></div>'
  })


  // NOTE: POPOVER EXTENDS tooltip.js
  // ================================

  Popover.prototype = $.extend({}, $.fn.tooltip.Constructor.prototype)

  Popover.prototype.constructor = Popover

  Popover.prototype.getDefaults = function () {
    return Popover.DEFAULTS
  }

  Popover.prototype.setContent = function () {
    var $tip    = this.tip()
    var title   = this.getTitle()
    var content = this.getContent()

    $tip.find('.popover-title')[this.options.html ? 'html' : 'text'](title)
    $tip.find('.popover-content').children().detach().end()[ // we use append for html objects to maintain js events
      this.options.html ? (typeof content == 'string' ? 'html' : 'append') : 'text'
    ](content)

    $tip.removeClass('fade top bottom left right in')

    // IE8 doesn't accept hiding via the `:empty` pseudo selector, we have to do
    // this manually by checking the contents.
    if (!$tip.find('.popover-title').html()) $tip.find('.popover-title').hide()
  }

  Popover.prototype.hasContent = function () {
    return this.getTitle() || this.getContent()
  }

  Popover.prototype.getContent = function () {
    var $e = this.$element
    var o  = this.options

    return $e.attr('data-content')
      || (typeof o.content == 'function' ?
            o.content.call($e[0]) :
            o.content)
  }

  Popover.prototype.arrow = function () {
    return (this.$arrow = this.$arrow || this.tip().find('.arrow'))
  }

  Popover.prototype.tip = function () {
    if (!this.$tip) this.$tip = $(this.options.template)
    return this.$tip
  }


  // POPOVER PLUGIN DEFINITION
  // =========================

  function Plugin(option) {
    return this.each(function () {
      var $this    = $(this)
      var data     = $this.data('bs.popover')
      var options  = typeof option == 'object' && option
      var selector = options && options.selector

      if (!data && option == 'destroy') return
      if (selector) {
        if (!data) $this.data('bs.popover', (data = {}))
        if (!data[selector]) data[selector] = new Popover(this, options)
      } else {
        if (!data) $this.data('bs.popover', (data = new Popover(this, options)))
      }
      if (typeof option == 'string') data[option]()
    })
  }

  var old = $.fn.popover

  $.fn.popover             = Plugin
  $.fn.popover.Constructor = Popover


  // POPOVER NO CONFLICT
  // ===================

  $.fn.popover.noConflict = function () {
    $.fn.popover = old
    return this
  }

}(jQuery);
$(document).ready(function(argument) {
	// body...

	$.each($('.tab-container'), function(){
		var index = $(this).find('.tab').find('.current').index();

		this.onceLoadedTab = [];
		tabShowIndex($(this), index);

		var trigger = $(this).data('trigger'),
			$self = $(this);

		$(this).on(trigger, '.tab>a', function(){
			$(this).siblings().removeClass('current').end().addClass('current');

			tabShowIndex($self, $(this).index());

		    //tab切换时,需调整列宽:http://datatables.club/reference/api/%24.fn.dataTable.tables().html
			$.fn.dataTable.tables({ visible: true, api: true }).columns.adjust();
		});
	});
	

	function tabShowIndex($tab, index){
	    $tab.find('.tab-content-item').hide().eq(index).show();

	    /*切换tab后的事件，为了可以进行异步加载tab内容的操作--wxj20180530
          参数：index:索引,onceLoaded是否曾经加载过*/
	    var onceLoaded = $tab[0].onceLoadedTab.indexOf(index) > -1;
	    $tab.trigger('tabChanged', [index, onceLoaded]);
	    if (!onceLoaded) { $tab[0].onceLoadedTab.push(index); }
	}

});
;!function(a,b){
"use strict";
var c,d,
e="", //组件存放目录，为空表示自动获取
f={getPath:function(){var a=document.scripts,b=a[a.length-1].src;return e?e:b.substring(0,b.lastIndexOf("/")+1)},type:["dialog","page","iframe","loading","tips"]};a.layer={v:"1.8.5",ie6:!!a.ActiveXObject&&!a.XMLHttpRequest,index:0,path:f.getPath(),use:function(a,b){var d=c("head")[0],a=a.replace(/\s/g,""),e=/\.css$/.test(a),f=document.createElement(e?"link":"script"),g=a.replace(/\.|\//g,"");e&&(f.type="text/css",f.rel="stylesheet"),f[e?"href":"src"]=/^http:\/\//.test(a)?a:layer.path+a,f.id=g,c("#"+g)[0]||d.appendChild(f),b&&(document.all?c(f).ready(b):c(f).load(b))},alert:function(a,b,d,e){var f="function"==typeof d,g={dialog:{msg:a,type:b,yes:f?d:e},area:["auto","auto"]};return f||(g.title=d),c.layer(g)},confirm:function(a,b,d,e){var f="function"==typeof d,g={dialog:{msg:a,type:4,btns:2,yes:b,no:f?d:e}};return f||(g.title=d),c.layer(g)},msg:function(a,d,e,f){var g={title:!1,closeBtn:!1,time:d===b?2:d,dialog:{msg:""===a||a===b?"&nbsp;":a},end:f};return"object"==typeof e?(g.dialog.type=e.type,g.shade=e.shade,g.shift=e.rate):"function"==typeof e?g.end=e:g.dialog.type=e,c.layer(g)},load:function(a,b){return"string"==typeof a?layer.msg(a,b||0,16):c.layer({time:a,loading:{type:b},bgcolor:b?"#fff":"",shade:b?[.1,"#000"]:[0],border:3!==b&&b?[6,.3,"#000"]:[0],type:3,title:["",!1],closeBtn:[0,!1]})},tips:function(a,b,d,e,f,g){var h={type:4,shade:!1,success:function(a){this.closeBtn||a.find(".xubox_tips").css({"padding-right":10})},bgcolor:"",tips:{msg:a,follow:b}};return h.time="object"==typeof d?d.time:0|d,d=d||{},h.closeBtn=d.closeBtn||!1,h.maxWidth=d.maxWidth||e,h.tips.guide=d.guide||f,h.tips.style=d.style||g,h.tips.more=d.more,c.layer(h)}};var g=["xubox_layer","xubox_iframe",".xubox_title",".xubox_text",".xubox_page",".xubox_main"],h=function(a){var b=this,d=b.config;layer.index++,b.index=layer.index,b.config=c.extend({},d,a),b.config.dialog=c.extend({},d.dialog,a.dialog),b.config.page=c.extend({},d.page,a.page),b.config.iframe=c.extend({},d.iframe,a.iframe),b.config.loading=c.extend({},d.loading,a.loading),b.config.tips=c.extend({},d.tips,a.tips),b.creat()};h.pt=h.prototype,h.pt.config={type:0,shade:[.3,"#000"],fix:!0,move:".xubox_title",title:"&#x4FE1;&#x606F;",offset:["","50%"],area:["310px","auto"],closeBtn:[0,!0],time:0,bgcolor:"#fff",border:[6,.3,"#000"],zIndex:19891014,maxWidth:400,dialog:{btns:1,btn:["&#x786E;&#x5B9A;","&#x53D6;&#x6D88;"],type:8,msg:"",yes:function(a){layer.close(a)},no:function(a){layer.close(a)}},page:{dom:"#xulayer",html:"",url:""},iframe:{src:"http://sentsin.com",scrolling:"auto"},loading:{type:0},tips:{msg:"",follow:"",guide:0,isGuide:!0,style:["background-color:#FF9900; color:#fff;","#FF9900"]},success:function(){},close:function(a){layer.close(a)},end:function(){}},h.pt.space=function(a){var b=this,a=a||"",c=b.index,d=b.config,e=d.dialog,f=-1===e.type?"":'<span class="xubox_msg xulayer_png32 xubox_msgico xubox_msgtype'+e.type+'"></span>',h=['<div class="xubox_dialog">'+f+'<span class="xubox_msg xubox_text" style="'+(f?"":"padding-left:20px")+'">'+e.msg+"</span></div>",'<div class="xubox_page">'+a+"</div>",'<iframe scrolling="'+d.iframe.scrolling+'" allowtransparency="true" id="'+g[1]+c+'" name="'+g[1]+c+'" onload="this.className=\''+g[1]+'\'" class="'+g[1]+'" frameborder="0" src="'+d.iframe.src+'"></iframe>','<span class="xubox_loading xubox_loading_'+d.loading.type+'"></span>','<div class="xubox_tips" style="'+d.tips.style[0]+'"><div class="xubox_tipsMsg">'+d.tips.msg+'</div><i class="layerTipsG"></i></div>'],i="",j="",k=d.zIndex+c,l="z-index:"+k+"; background-color:"+d.shade[1]+"; opacity:"+d.shade[0]+"; filter:alpha(opacity="+100*d.shade[0]+");";d.shade[0]&&(i='<div times="'+c+'" id="xubox_shade'+c+'" class="xubox_shade" style="'+l+'"></div>'),d.zIndex=k;var m="",n="",o="z-index:"+(k-1)+";  background-color: "+d.border[2]+"; opacity:"+d.border[1]+"; filter:alpha(opacity="+100*d.border[1]+"); top:-"+d.border[0]+"px; left:-"+d.border[0]+"px;";d.border[0]&&(j='<div id="xubox_border'+c+'" class="xubox_border" style="'+o+'"></div>'),!d.maxmin||1!==d.type&&2!==d.type||/^\d+%$/.test(d.area[0])&&/^\d+%$/.test(d.area[1])||(n='<a class="xubox_min" href="javascript:;"><cite></cite></a><a class="xubox_max xulayer_png32" href="javascript:;"></a>'),d.closeBtn[1]&&(n+='<a class="xubox_close xulayer_png32 xubox_close'+d.closeBtn[0]+'" href="javascript:;" style="'+(4===d.type?"position:absolute; right:-3px; _right:7px; top:-4px;":"")+'"></a>');var p="object"==typeof d.title;return d.title&&(m='<div class="xubox_title" style="'+(p?d.title[1]:"")+'"><em>'+(p?d.title[0]:d.title)+"</em></div>"),[i,'<div times="'+c+'" showtime="'+d.time+'" style="z-index:'+k+'" id="'+g[0]+c+'" class="'+g[0]+'"><div style="background-color:'+d.bgcolor+"; z-index:"+k+'" class="xubox_main">'+h[d.type]+m+'<span class="xubox_setwin">'+n+'</span><span class="xubox_botton"></span></div>'+j+"</div>"]},h.pt.creat=function(){var a=this,b="",d=a.config,e=d.dialog,f=a.index,h=d.page,i=c("body"),j=function(d){var d=d||"";b=a.space(d),i.append(c(b[0]))};switch(d.type){case 0:d.title||(d.area=["auto","auto"]),c(".xubox_dialog")[0]&&layer.close(c(".xubox_dialog").parents("."+g[0]).attr("times"));break;case 1:if(""!==h.html)j('<div class="xuboxPageHtml">'+h.html+"</div>"),i.append(c(b[1]));else if(""!==h.url)j('<div class="xuboxPageHtml" id="xuboxPageHtml'+f+'">'+h.html+"</div>"),i.append(c(b[1])),c.get(h.url,function(a){c("#xuboxPageHtml"+f).html(a.toString()),h.ok&&h.ok(a)});else{if(0!=c(h.dom).parents(g[4]).length)return;j(),c(h.dom).show().wrap(c(b[1]))}break;case 3:d.title=!1,d.area=["auto","auto"],d.closeBtn=["",!1],c(".xubox_loading")[0]&&layer.closeLoad();break;case 4:d.title=!1,d.area=["auto","auto"],d.fix=!1,d.border=[0],d.tips.more||layer.closeTips()}1!==d.type&&(j(),i.append(c(b[1])));var k=a.layerE=c("#"+g[0]+f);if(k.css({width:d.area[0],height:d.area[1]}),d.fix||k.css({position:"absolute"}),d.title&&(3!==d.type||4!==d.type)){var l=0===d.type?e:d,m=k.find(".xubox_botton");switch(l.btn=d.btn||e.btn,l.btns){case 0:m.html("").hide();break;case 1:m.html('<a href="javascript:;" class="xubox_yes xubox_botton1">'+l.btn[0]+"</a>");break;case 2:m.html('<a href="javascript:;" class="xubox_yes xubox_botton2">'+l.btn[0]+'</a><a href="javascript:;" class="xubox_no xubox_botton3">'+l.btn[1]+"</a>")}}"auto"===k.css("left")?(k.hide(),setTimeout(function(){k.show(),a.set(f)},500)):a.set(f),d.time<=0||a.autoclose(),a.callback()},f.fade=function(a,b,c){a.css({opacity:0}).animate({opacity:c},b)},h.pt.offset=function(){var a=this,b=a.config,c=a.layerE,e=c.outerHeight();a.offsetTop=""===b.offset[0]&&e<d.height()?(d.height()-e-2*b.border[0])/2:-1!=b.offset[0].indexOf("px")?parseFloat(b.offset[0]):parseFloat(b.offset[0]||0)/100*d.height(),a.offsetTop=a.offsetTop+b.border[0]+(b.fix?0:d.scrollTop()),-1!=b.offset[1].indexOf("px")?a.offsetLeft=parseFloat(b.offset[1])+b.border[0]:(b.offset[1]=""===b.offset[1]?"50%":b.offset[1],a.offsetLeft="50%"===b.offset[1]?b.offset[1]:parseFloat(b.offset[1])/100*d.width()+b.border[0])},h.pt.set=function(a){var b=this,e=b.config,h=(e.dialog,e.page),i=(e.loading,b.layerE),j=i.find(g[2]);switch(b.autoArea(a),e.title?0===e.type&&layer.ie6&&j.css({width:i.outerWidth()}):4!==e.type&&i.find(".xubox_close").addClass("xubox_close1"),i.attr({type:f.type[e.type]}),b.offset(),4!==e.type&&(e.shift&&!layer.ie6?"object"==typeof e.shift?b.shift(e.shift[0],e.shift[1]||500,e.shift[2]):b.shift(e.shift,500):i.css({top:b.offsetTop,left:b.offsetLeft})),e.type){case 0:i.find(g[5]).css({"background-color":"#fff"}),e.title?i.find(g[3]).css({paddingTop:18+j.outerHeight()}):(i.find(".xubox_msgico").css({top:8}),i.find(g[3]).css({marginTop:11}));break;case 1:i.find(h.dom).addClass("layer_pageContent"),e.shade[0]&&i.css({zIndex:e.zIndex+1}),e.title&&i.find(g[4]).css({top:j.outerHeight()});break;case 2:var k=i.find("."+g[1]),l=i.height();k.addClass("xubox_load").css({width:i.width()}),k.css(e.title?{top:j.height(),height:l-j.height()}:{top:0,height:l}),layer.ie6&&k.attr("src",e.iframe.src);break;case 4:var m=[0,i.outerHeight()],n=c(e.tips.follow),o={width:n.outerWidth(),height:n.outerHeight(),top:n.offset().top,left:n.offset().left},p=i.find(".layerTipsG");e.tips.isGuide||p.remove(),i.outerWidth()>e.maxWidth&&i.width(e.maxWidth),o.tipColor=e.tips.style[1],m[0]=i.outerWidth(),o.autoLeft=function(){o.left+m[0]-d.width()>0?(o.tipLeft=o.left+o.width-m[0],p.css({right:12,left:"auto"})):o.tipLeft=o.left},o.where=[function(){o.autoLeft(),o.tipTop=o.top-m[1]-10,p.removeClass("layerTipsB").addClass("layerTipsT").css({"border-right-color":o.tipColor})},function(){o.tipLeft=o.left+o.width+10,o.tipTop=o.top,p.removeClass("layerTipsL").addClass("layerTipsR").css({"border-bottom-color":o.tipColor})},function(){o.autoLeft(),o.tipTop=o.top+o.height+10,p.removeClass("layerTipsT").addClass("layerTipsB").css({"border-right-color":o.tipColor})},function(){o.tipLeft=o.left-m[0]+10,o.tipTop=o.top,p.removeClass("layerTipsR").addClass("layerTipsL").css({"border-bottom-color":o.tipColor})}],o.where[e.tips.guide](),0===e.tips.guide?o.top-(d.scrollTop()+m[1]+16)<0&&o.where[2]():1===e.tips.guide?d.width()-(o.left+o.width+m[0]+16)>0||o.where[3]():2===e.tips.guide?o.top-d.scrollTop()+o.height+m[1]+16-d.height()>0&&o.where[0]():3===e.tips.guide?m[0]+16-o.left>0&&o.where[1]():4===e.tips.guide,i.css({left:o.tipLeft,top:o.tipTop})}e.fadeIn&&(f.fade(i,e.fadeIn,1),f.fade(c("#xubox_shade"+a),e.fadeIn,e.shade[0])),e.fix&&""===e.offset[0]&&!e.shift&&d.on("resize",function(){i.css({top:(d.height()-i.outerHeight())/2})}),b.move()},h.pt.shift=function(a,b,c){var e=this,f=e.config,g=e.layerE,h=0,i=d.width(),j=d.height()+(f.fix?0:d.scrollTop());h="50%"==f.offset[1]||""==f.offset[1]?g.outerWidth()/2:g.outerWidth();var k={t:{top:e.offsetTop},b:{top:j-g.outerHeight()-f.border[0]},cl:h+f.border[0],ct:-g.outerHeight(),cr:i-h-f.border[0]};switch(a){case"left-top":g.css({left:k.cl,top:k.ct}).animate(k.t,b);break;case"top":g.css({top:k.ct}).animate(k.t,b);break;case"right-top":g.css({left:k.cr,top:k.ct}).animate(k.t,b);break;case"right-bottom":g.css({left:k.cr,top:j}).animate(c?k.t:k.b,b);break;case"bottom":g.css({top:j}).animate(c?k.t:k.b,b);break;case"left-bottom":g.css({left:k.cl,top:j}).animate(c?k.t:k.b,b);break;case"left":g.css({left:-g.outerWidth()}).animate({left:e.offsetLeft},b)}},h.pt.autoArea=function(a){var b,d=this,a=a||d.index,e=d.config,f=e.page,h=c("#"+g[0]+a),i=h.find(g[2]),j=h.find(g[5]),k=e.title?i.innerHeight():0,l=0;switch("auto"===e.area[0]&&j.outerWidth()>=e.maxWidth&&h.css({width:e.maxWidth}),e.type){case 0:var m=h.find(".xubox_botton>a");b=h.find(g[3]).outerHeight()+20,m.length>0&&(l=m.outerHeight()+20);break;case 1:var n=h.find(g[4]);b=c(f.dom).outerHeight(),"auto"===e.area[0]&&h.css({width:n.outerWidth()}),(""!==f.html||""!==f.url)&&(b=n.outerHeight());break;case 2:h.find("iframe").css({width:h.outerWidth(),height:h.outerHeight()-(e.title?i.innerHeight():0)});break;case 3:var o=h.find(".xubox_loading");b=o.outerHeight(),j.css({width:o.width()})}"auto"===e.area[1]&&j.css({height:k+b+l}),c("#xubox_border"+a).css({width:h.outerWidth()+2*e.border[0],height:h.outerHeight()+2*e.border[0]}),layer.ie6&&"auto"!==e.area[0]&&j.css({width:h.outerWidth()}),h.css("50%"!==e.offset[1]&&""!=e.offset[1]||4===e.type?{marginLeft:0}:{marginLeft:-h.outerWidth()/2})},h.pt.move=function(){var a=this,b=a.config,e={setY:0,moveLayer:function(){if(0==parseInt(e.layerE.css("margin-left")))var a=parseInt(e.move.css("left"));else var a=parseInt(e.move.css("left"))+-parseInt(e.layerE.css("margin-left"));"fixed"!==e.layerE.css("position")&&(a-=e.layerE.parent().offset().left,e.setY=0),e.layerE.css({left:a,top:parseInt(e.move.css("top"))-e.setY})}},f=a.layerE.find(b.move);b.move&&f.attr("move","ok"),f.css(b.move?{cursor:"move"}:{cursor:"auto"}),c(b.move).on("mousedown",function(a){if(a.preventDefault(),"ok"===c(this).attr("move")){e.ismove=!0,e.layerE=c(this).parents("."+g[0]);var f=e.layerE.offset().left,h=e.layerE.offset().top,i=e.layerE.width()-6,j=e.layerE.height()-6;c("#xubox_moves")[0]||c("body").append('<div id="xubox_moves" class="xubox_moves" style="left:'+f+"px; top:"+h+"px; width:"+i+"px; height:"+j+'px; z-index:2147483584"></div>'),e.move=c("#xubox_moves"),b.moveType&&e.move.css({opacity:0}),e.moveX=a.pageX-e.move.position().left,e.moveY=a.pageY-e.move.position().top,"fixed"!==e.layerE.css("position")||(e.setY=d.scrollTop())}}),c(document).mousemove(function(a){if(e.ismove){var c=a.pageX-e.moveX,f=a.pageY-e.moveY;if(a.preventDefault(),!b.moveOut){e.setY=d.scrollTop();var g=d.width()-e.move.outerWidth()-b.border[0],h=b.border[0]+e.setY;c<b.border[0]&&(c=b.border[0]),c>g&&(c=g),h>f&&(f=h),f>d.height()-e.move.outerHeight()-b.border[0]+e.setY&&(f=d.height()-e.move.outerHeight()-b.border[0]+e.setY)}e.move.css({left:c,top:f}),b.moveType&&e.moveLayer(),c=null,f=null,g=null,h=null}}).mouseup(function(){try{e.ismove&&(e.moveLayer(),e.move.remove()),e.ismove=!1}catch(a){e.ismove=!1}b.moveEnd&&b.moveEnd()})},h.pt.autoclose=function(){var a=this,b=a.config.time,c=function(){b--,0===b&&(layer.close(a.index),clearInterval(a.autotime))};a.autotime=setInterval(c,1e3)},f.config={end:{}},h.pt.callback=function(){var a=this,b=a.layerE,d=a.config,e=d.dialog;a.openLayer(),a.config.success(b),layer.ie6&&a.IE6(b),b.find(".xubox_close").on("click",function(){d.close(a.index),layer.close(a.index)}),b.find(".xubox_yes").on("click",function(){d.yes?d.yes(a.index):e.yes(a.index)}),b.find(".xubox_no").on("click",function(){d.no?d.no(a.index):e.no(a.index),layer.close(a.index)}),a.config.shadeClose&&c("#xubox_shade"+a.index).on("click",function(){layer.close(a.index)}),b.find(".xubox_min").on("click",function(){layer.min(a.index,d),d.min&&d.min(b)}),b.find(".xubox_max").on("click",function(){c(this).hasClass("xubox_maxmin")?(layer.restore(a.index),d.restore&&d.restore(b)):(layer.full(a.index,d),d.full&&d.full(b))}),f.config.end[a.index]=d.end},f.reselect=function(){c.each(c("select"),function(){var a=c(this);a.parents("."+g[0])[0]||1==a.attr("layer")&&c("."+g[0]).length<1&&a.removeAttr("layer").show(),a=null})},h.pt.IE6=function(a){var b=this,e=a.offset().top;if(b.config.fix)var f=function(){a.css({top:d.scrollTop()+e})};else var f=function(){a.css({top:e})};f(),d.scroll(f),c.each(c("select"),function(){var a=c(this);a.parents("."+g[0])[0]||"none"==a.css("display")||a.attr({layer:"1"}).hide(),a=null})},h.pt.openLayer=function(){{var a=this;a.layerE}layer.autoArea=function(b){return a.autoArea(b)},layer.shift=function(b,c,d){a.shift(b,c,d)},layer.setMove=function(){return a.move()},layer.zIndex=a.config.zIndex,layer.setTop=function(a){var b=function(){layer.zIndex++,a.css("z-index",layer.zIndex+1)};return layer.zIndex=parseInt(a[0].style.zIndex),a.on("mousedown",b),layer.zIndex}},f.isauto=function(a,b,c){"auto"===b.area[0]&&(b.area[0]=a.outerWidth()),"auto"===b.area[1]&&(b.area[1]=a.outerHeight()),a.attr({area:b.area+","+c}),a.find(".xubox_max").addClass("xubox_maxmin")},f.rescollbar=function(a){g.html.attr("layer-full")==a&&(g.html[0].style.removeProperty?g.html[0].style.removeProperty("overflow"):g.html[0].style.removeAttribute("overflow"),g.html.removeAttr("layer-full"))},layer.getIndex=function(a){return c(a).parents("."+g[0]).attr("times")},layer.getChildFrame=function(a,b){return b=b||c("."+g[1]).parents("."+g[0]).attr("times"),c("#"+g[0]+b).find("."+g[1]).contents().find(a)},layer.getFrameIndex=function(a){return c(a?"#"+a:"."+g[1]).parents("."+g[0]).attr("times")},layer.iframeAuto=function(a){a=a||c("."+g[1]).parents("."+g[0]).attr("times");var b=layer.getChildFrame("body",a).outerHeight(),d=c("#"+g[0]+a),e=d.find(g[2]),f=0;e&&(f=e.height()),d.css({height:b+f});var h=-parseInt(c("#xubox_border"+a).css("top"));c("#xubox_border"+a).css({height:b+2*h+f}),c("#"+g[1]+a).css({height:b})},layer.iframeSrc=function(a,b){c("#"+g[0]+a).find("iframe").attr("src",b)},layer.area=function(a,b){var d=[c("#"+g[0]+a),c("#xubox_border"+a)],e=d[0].attr("type"),h=d[0].find(g[5]),i=d[0].find(g[2]);if(e===f.type[1]||e===f.type[2]){if(d[0].css(b),h.css({width:b.width,height:b.height}),e===f.type[2]){var j=d[0].find("iframe");j.css({width:b.width,height:i?b.height-i.innerHeight():b.height})}"0px"!==d[0].css("margin-left")&&(b.hasOwnProperty("top")&&d[0].css({top:b.top-(d[1][0]?parseFloat(d[1].css("top")):0)}),b.hasOwnProperty("left")&&d[0].css({left:b.left+d[0].outerWidth()/2-(d[1][0]?parseFloat(d[1].css("left")):0)}),d[0].css({marginLeft:-d[0].outerWidth()/2})),d[1][0]&&d[1].css({width:parseFloat(b.width)-2*parseFloat(d[1].css("left")),height:parseFloat(b.height)-2*parseFloat(d[1].css("top"))})}},layer.min=function(a,b){var d=c("#"+g[0]+a),e=[d.position().top,d.position().left+parseFloat(d.css("margin-left"))];f.isauto(d,b,e),layer.area(a,{width:180,height:35}),d.find(".xubox_min").hide(),"page"===d.attr("type")&&d.find(g[4]).hide(),f.rescollbar(a)},layer.restore=function(a){{var b=c("#"+g[0]+a),d=b.attr("area").split(",");b.attr("type")}layer.area(a,{width:parseFloat(d[0]),height:parseFloat(d[1]),top:parseFloat(d[2]),left:parseFloat(d[3])}),b.find(".xubox_max").removeClass("xubox_maxmin"),b.find(".xubox_min").show(),"page"===b.attr("type")&&b.find(g[4]).show(),f.rescollbar(a)},layer.full=function(a,b){var e,h=c("#"+g[0]+a),i=2*b.border[0]||6,j=[h.position().top,h.position().left+parseFloat(h.css("margin-left"))];f.isauto(h,b,j),g.html.attr("layer-full")||g.html.css("overflow","hidden").attr("layer-full",a),clearTimeout(e),e=setTimeout(function(){layer.area(a,{top:"fixed"===h.css("position")?0:d.scrollTop(),left:"fixed"===h.css("position")?0:d.scrollLeft(),width:d.width()-i,height:d.height()-i})},100)},layer.title=function(a,b){var d=c("#"+g[0]+(b||layer.index)).find(".xubox_title>em");d.html(a)},layer.close=function(a){var b=c("#"+g[0]+a),d=b.attr("type"),e=c("#xubox_moves, #xubox_shade"+a);if(b[0]){if(d==f.type[1])if(b.find(".xuboxPageHtml")[0])b[0].innerHTML="",b.remove();else{b.find(".xubox_setwin,.xubox_close,.xubox_botton,.xubox_title,.xubox_border").remove();for(var h=0;3>h;h++)b.find(".layer_pageContent").unwrap().hide()}else b[0].innerHTML="",b.remove();e.remove(),layer.ie6&&f.reselect(),f.rescollbar(a),"function"==typeof f.config.end[a]&&f.config.end[a](),delete f.config.end[a]}},layer.closeLoad=function(){layer.close(c(".xubox_loading").parents("."+g[0]).attr("times"))},layer.closeTips=function(){layer.closeAll("tips")},layer.closeAll=function(a){c.each(c("."+g[0]),function(){var b=c(this),d=a?b.attr("type")===a:1;d&&layer.close(b.attr("times")),d=null})},f.run=function(){c=jQuery,d=c(a),g.html=c("html"),layer.use("skin/layer.css"),c.layer=function(a){var b=new h(a);return b.index},(new Image).src=layer.path+"skin/default/xubox_ico0.png"},"function"==typeof define?define(function(){return f.run(),layer}):f.run()}(window);

$(document).ready(function(){
	
	// 去除虚线框（会影响效率）
	$("a").on('focus',function(){$(this).blur();});
	
	
	$('.file input[type=file]').change(function(e) {
        $(this).siblings('.text').text($(this).val());
    });

	////$("tbody").find("tr:odd").css("backgroundColor", "#eff6fa");
    //$(".table .table-box tbody").find("tr:odd").css("backgroundColor", "#eff6fa");//用了DataTables就不需要这样--wxj20180514    
	if ($pf.setOddEvenRowCss !== undefined) {//最外层frame里使用了sapar.js但没使用pfUtil
	    $pf.setOddEvenRowCss($(".table .table-box tbody"));
	}
});


function hideElement(currentElement, targetElement, fn) {
	if (!$.isArray(targetElement)) {
		targetElement = [ targetElement ];
	}
	$(document).on("click.hideElement", function(e) {
		var len = 0, $target = $(e.target);
		for (var i = 0, length = targetElement.length; i < length; i++) {
			$.each(targetElement[i], function(j, n) {
				if ($target.is($(n)) || $.contains($(n)[0], $target[0])) {
					len++;
				}
			});
		}
		if ($.contains(currentElement[0], $target[0])) {
			len = 1;
		}
		if (len == 0) {
			currentElement.hide();
			fn && fn(currentElement, targetElement);
		}
	});
}


/*
 *  用来给不支持HTML5 placeholder属性的浏览器增加此功能。
 *  @param element {String or Object} 需要添加placeholder提示的输入框选择器或者输入框jquery对象。
 *  @param defualtCss {String} 提示默认的样式class。
 */

function showRemind(element,defualtCss){
	if(-[1,]){
		return false;
	}

	$(element).each(function(el, i){
		var placeholder = $(this).attr('placeholder');
		if(placeholder){
			$(this).addClass(defualtCss).val(placeholder);
			$(this).focus(function(e){
				if($(this).attr('placeholder') === $(this).val()){
					$(this).val('').removeClass(defualtCss);
				}
			});

			$(this).blur(function(e){
				if($(this).val() === ""){
					$(this).addClass(defualtCss).val($(this).attr('placeholder'));
				}
			});
		}
	});
}

function resize(resizeHandle){
	var d = document.documentElement;
	var timer;//避免resize触发多次,影响性能
	var width = d.clientWidth, height = d.clientHeight;
	$(top.window).on('resize',function(e){
		if((width != d.clientWidth || height != d.clientHeight)){
			width = d.clientWidth, height = d.clientHeight;
			if(timer){clearTimeout(timer);}
			timer = setTimeout(function(){
				resizeHandle();
			},10);	
		}
	});
	
}

